1

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!

Michael Haren
  • 1,301
  • 7
  • 18
  • 31

2 Answers2

6

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.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
1

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.

chrskly
  • 1,569
  • 12
  • 16
  • 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 .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 02:58