Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

EC2 servers spawned via Rightscale have reasonable nicknames like foo_03 inside Rightscale UI. These nicknames seem to be completely disconnected from anything else in EC2 - they're not even anywhere in /etc or /var/spool/ec2. This isn't really a big deal as I can figure them out from instance IP plus a few XML requests to Rightscale.

The question is - is there a way to get such nicknames into DNS system? I'd like to resolve to foo_03's IP address, and especially I'd like foo_03's IP address to reverse resolve to

I don't need it for anything facing end user, only to see which connection comes from which server.

How difficult would it be? (/etc/hosts hacks might be sort of acceptable I guess).

share|improve this question

As you suggest: query EC2 for your list of instances, query more to get the nicknames and the IP addresses. Build an /etc/hosts file from that. This method has to be done on every machine (unless you distribute said /etc/hosts file around)

If you have access to your nameserver and it's running Bind or the like that takes its configuration from text files, you could adapt the above script to write out a subdomain text file (so it's like and then point bind at said config file (If you don't care about reverse lookups, you could write out CNAME records instead of A records). Make the TTL on it low so it will get reloaded fairly often. Run the script in a cron job every 5 or 10 minutes (it's the only server doing this, so you can do it more often if you like). Reverse lookups are a little more difficult; you'll have to figure out the right files (basically figure out what range of IPs amazon is adding to the cloud) and make sure bind is configured to look at them.

If there's a hookable DNS serve that you could cause to re-query whenever someone asks for something in the subdomain, that would be ideal, but I don't know if bind can be made to do such a thing.

share|improve this answer
Would that solve reverse lookup as well? Rechecking list of instances every 5 minutes on one server is fine - rechecking it every 5 minutes on every server doesn't seem like such a great idea. – taw Jul 28 '10 at 5:07

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.