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.

How can I re-map one hostname to another, similar to how one would re-map a hostname to an IP in /etc/hosts?

For instance, how could I map oneheckofalongdomainname.com to a.com on my local machine?

Adding an entry into /etc/hosts won't work as it maps hostnames to IP addresses, whereas I need to map one hostname to another. I'm also unable to use the target domain's IP because it's subject to change.

share|improve this question

3 Answers 3

You can do so, but this would require a name server and cannot be done by an /etc/hosts entry. You need to forward a CNAME to another CNAME. If it is just temporary you might be ok with resolving the IP address for the hostname you wish to forward and put this into /etc/hosts or - if it is a web page you wish to forward, you could set up Apache accordingly. But for all other services (nfs, rsync, ftp) you will probably not be able to do it without a (dummy) name server.

See also here

share|improve this answer

Assuming that oneheckofalongdomainname.com is a live website, they probably have a static IP address. Ping oneheckofalongdomainname.com to resolve the DNS entry to an IP. Take that IP, and edit /etc/hosts to map a.com to the resulting IP.

Hope this helps!

share|improve this answer
    
Sorry, that's not what I asked. I'm unable to use the IP as it is subject to change. –  Phillip Oldham Feb 6 '11 at 15:42
    
Sorry, I missed that part of the post. My apologies –  spadge67 Feb 7 '11 at 15:45

Depending on what is on the other end a CNAME won't work either. If it is a website for example it could be using host headers which means it uses the domain name you request on in order to serve the correct website.

One way you could get around this would be to setup a local web server with a redirect to the long named domain. You would then point the short domain in /etc/hosts at the local address 127.0.0.1

share|improve this answer

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.