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

I'm wondering if it's possible to alias one domain for another at the server configuration level in a similar way that you can alias a domain to an IP address in the /etc/hosts file.

This is on a flavor of RedHat Linux.

I thought this would be simple to do but unfortunately I couldn't find where to configure this.

As an example: I would like to be able to add an alias to an actual DNS

To give some context, I want to use a consistent name in my application. The DB details change depending on the server the component is running on (e.g. regional differences). The DB DNS entries don't change names but the underlying IP addresses are prone to change so this is why mapping to IP address in /etc/hosts is not reliable.

I'd appreciate any advice


share|improve this question
First of all, why would you want to redirect to You could just use the second address directly, why hide that you're going to Amazon? Secondly, "the underlying IP addresses are prone to change so this is why mapping to IP address in /etc/hosts is not reliable" -- talk to whoever is responsible for the network here and has a clue about specifying static IPs for certain servers and/or setting up DNS rules instead of hacking this yourself. – pzkpfw Feb 17 '13 at 8:54

I'm having a little bit of a hard time following what it is that you want to do, but is a CNAME record what you're looking for?

share|improve this answer
Thanks, but alas a CNAME won't work. The issue is that I need to map the same DNS alias (CNAME) to different domain names depending on the server where the application is running. I am currently using /etc/hosts to map to the IP address of the necessary DNS but problem with this is that the IP address is prone to change. – cowper Feb 17 '13 at 1:59
This sounds like a hack to DNS to make what you want work. My initial logic was: create a script which periodically checks against a list of IPs you define, or which it scrapes itself, for particular services; as those IPs change, make the script push the change to the bind config (with the TTL set to a very low value) and reload it. – Christopher Woods Feb 17 '13 at 4:37
However it sounds like what you actually need to do is anycasting -- geolocation-aware DNS with BIND. Fortunately, others have already written about this in greater detail, including . The key here is a BIND feature called views which seems to accomplish exactly what you want. – Christopher Woods Feb 17 '13 at 4:39

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.