-1

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,

cowper
  • 111
  • 2
  • 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. – pzkpfw Feb 17 '13 at 08:54

1 Answers1

0

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?

MDMarra
  • 100,734
  • 32
  • 197
  • 329
  • 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 01: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. – Chris Woods Feb 17 '13 at 04: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 http://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. – Chris Woods Feb 17 '13 at 04:39