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.

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 db.myapp.com to an actual DNS db.rds.amazonaws.com

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

Thanks,

share|improve this question
    
First of all, why would you want to redirect db.myapp.com to db.rds.amazonaws.com? 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. –  bigbadonk420 Feb 17 '13 at 8:54

1 Answer 1

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 backreference.org/2010/02/01/geolocation-aware-dns-with-bind . 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

 
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.