Tuesday, December 23, 2014

ubuntu - CNAME : how to setup DNS to return A record based on website?



I have a query regarding setting up servers.



Suppose I have multiple websites to host.




foo.com
bar.com
hello.com


I may or may not to have specific servers for them. Suppose an arbitrary configuration is something like this (with the respective domain registrar)



foo.com  A  1.1.1.1
bar.com A 1.1.1.2
hello.com A 1.1.1.1



What I would like is to give each website a universal domain to point to instead of an IP (since IP can change).



something like the following.



foo.com CNAME service.com
bar.com CNAME service.com
hello.com CNAME service.com



From what I have understood about DNS so far,



Queries




  1. I think I will need to setup a DNS server at service.com which returns the appropriate records.


    • Is this correct?



  2. If so what if domain is held with a domain registrar? such as dreamhost. How to handle it then?


    • Since they respond to DNS queries, how do I insert that layer of indirection?




Achieve transparent server migration from client's perspective




Ultimately what I would like to achieve is that if I were to one day host hello.com from a different server, I would only have to modify in 1 place at the server rather then tell the client to change their DNS config.



Additional Info:



I use rackspace, they also have something called reverse DNS. Is that useful?



I noticed for google Apps - we always point to ghs.google.com and they forward the request to appropriate IP. So it must be possible, but I just can't figure out how to achieve it.


Answer



You'd need a separate cname per site. Something like:




foot.com CNAME foo.com.service.com
bar.com CNAME bar.com.service.com
hello.com CNAME hello.com.service.com

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...