Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Suppose I spin up a machine in EC2. Every time I stop/start the machine the following things change (reboots are safe--they don't cause these to change):

  • public IP address
  • public DNS record
  • private IP address
  • private DNS record
  • removes associated elastic IP

How can I reliably connect to the machine if the addresses/DNS records change every time it is started?

Should I stick with EIPs but add a startup script to reassociate it with my instance when it boots?

There's got to be a better way!

share|improve this question

2 Answers 2

If you stop an instance in EC2, then any associated Elastic IPs are disassociated, and you must reassociate them yourself. However, the same doesn't apply to instances in VPC; in this case the Elastic IP remains associated, even when the instance is stopped.

See the Elastic IP Address documentation for further details.

share|improve this answer
1  
+1 for VPC. A little extra setup work for a huge amount of extra functionality. –  ceejayoz Feb 13 '13 at 22:04
    
Thanks, Michael, this is helpful –  Michael Haren Feb 14 '13 at 13:45

Another possibility is to use a dynamic DNS service like dyndns.org. You install a client on the server which periodically checks it's IP agains a DNS record. If it's different it pushes out an update.

share|improve this answer
2  
If you're going to do that, there's really no good reason not to just have a client that re-attaches the Elastic IP itself. –  ceejayoz Feb 13 '13 at 22:35
    
If you have more than a handful of instances it can be easier to manage. –  chrskly Feb 13 '13 at 22:39
    
I don't see why it would be. You're going to have to set each server up with one or the other, and binding an EIP to an instance doesn't require much work at all. Hell, if you're using Amazon's Linux distro, the tools are already built into the instance - a simple @reboot cron one-liner would do the trick. –  ceejayoz Feb 13 '13 at 22:43
    
Say you have 100 servers. You need get Amazon to give you those addresses first. Then you need to map them to instances and configure each machine so that it know's it's IP - i.e. sub in the IP in your cron script. Whereas, if you used a dynamic dns service you could push the same config to all of the servers - i.e., just set the record to <hostname>.dynamicdomain.com. –  chrskly Feb 13 '13 at 22:59
    
If you have 100 AWS instances, you are almost certainly using a VPC with a proper configuration management system that handles all this for you without a reliance on an external dynamic DNS system. –  ceejayoz Feb 14 '13 at 2:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.