Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Looking for a "best practice" answer to managing externally-addressable hosts using the combination of Amazon EC2 and Amazon Route 53, without using Elastic IPs for each host. In my scenario I will have 30+ hosts that need to be accessible from outside EC2, so directly using internal DNS will not work.

In the past, I have addressed hosts by assigning an elastic IP to that host (let's say, and then creating an associated A record. For example, let's say I want to create "" I might do:     A     300

Then on that EC2 instance, I would assign the Elastic IP of, and everything works fine. Of course, to make this work, I need to have one Elastic IP per instance, which is something I'd like to avoid if possible; I'd like the infrastructure to be more dynamic.

So my thought is to try something like:

  • Create a script that queries the internal EC2 tools to determine an instance's private hostname

  • On instance boot, call that script to determine its hostname, and then using the command-line Route 53 interface to find and update that hostname to its current internal hostname

  • Since the host will have a relatively low TTL (let's say 300 as above, or 5 minutes) it should take effect pretty quickly

Is this a good idea? Is there a better or more widely accepted way to handle it?

If it IS a good idea, what type of record should I be creating? A CNAME that points to the internal host, like Is an A record better or worse?


share|improve this question
up vote 2 down vote accepted

Automate it. Just make part of the script that creates the new instance lookup the public IP (or the public name) by it's instance ID (you get the instance ID when you call ec2-run-instances; just keep calling ec2-describe-instances <instanceID> until you get an entry in the right field), then modify your DNS (it can be Route53, but doesn't have to be) to contain either a CNAME or A record with the data you obtained.

There might be some Route53 magic that'll do the trick, too, like there is with ELB, but I've not come across it.

share|improve this answer

For an A record; you would indeed need an Elastic IP for each instance. What I would do in such a case is as stated; assign each instance a CNAME using the AWS API for Route 53. If this is for something also like load balancing, i'd recommend using AWS Elastic Load Balancing service which will automate a lot of this (look into it some more to see if it fits your requirements as it is an additional fee).

share|improve this answer

Your Answer


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.