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 have a query regarding setting up servers.

Suppose I have multiple websites to host.

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

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. CNAME CNAME CNAME

From what I have understood about DNS so far,


  1. I think I will need to setup a DNS server at 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 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 and they forward the request to appropriate IP. So it must be possible, but I just can't figure out how to achieve it.

share|improve this question
up vote 1 down vote accepted

You'd need a separate cname per site. Something like: CNAME CNAME CNAME
share|improve this answer
So how does get resolved. The domain registrar will see and say I know this and return an IP. This might not be the IP where is actually hosted. I want to control that, but not sure how to. (refer to query 2) – Nasir Nov 4 '11 at 16:18
You set up an A record for in your DNS. If's IP needs to change, just change that A record. – ceejayoz Nov 4 '11 at 16:22
A note, though - you can't CNAME a root level domain. You can do it for www but the non-www will need to go to a server that kicks them to the www alias. – ceejayoz Nov 4 '11 at 16:23
Cname per site may be used. But common CNAME with short TTL is perfectly OK too – Lazy Badger Nov 4 '11 at 16:24
@LazyBadger A common CNAME won't work here. has a different IP address in the question. – ceejayoz Nov 4 '11 at 16:43

To set up DNS for a domain you own
On Dreamhost, make sure the name servers are set to Dreamhost name servers (they should be by default). Then set up the DNS with them (there should be a control panel to set up DNS records for the domain).

Some infos
CNAMEs just point to hostnames; those hostnames must be configured with IP addresses (ie, must have an A record pointing them to an IP).

If you have a few hostnames that need to be mapped to the same IP, then it can be easier setting up one hostname (A) to point to that IP, and then all other hostnames CNAME to that hostname (A).

If you have a few hostnames that need to point to different IPs, CNAMEs won't be much use.

So let's say you have,, and and you want to point them all to the same IP (taking note of @ceejayoz's comment about root domains and CNAMES). You'll need to set up one A record to point a hostname (say, to the IP, then set up CNAMEs for, and to point to

This will require you to have access to the DNS records for,, and (so if you've registered all of these domains with Dreamhost, you need to configure them all to use Dreamhost name servers, then setup the DNS records for each of them.

Specific answer to your question
You've mentioned, though, that you want to be able to modify the IP address for one domain without effecting the other; in this situation, you'll need to set up a CNAME for each domain name. Or, you can use reverse proxy (although it adds additional complexity). With a reverse proxy you can have all the domains using the same IP, regardless of what server they're on (the reverse proxy will forward the request onto the right server depending on what domain is being asked for). This is probably what Google Apps are doing.

Reverse DNS will not help you for this, but is useful (especially for email delivery). I won't go into it now, but you should read up on it!

share|improve this answer

Keep in mind that you won't be able to use CNAMEs for second level domains like "" because they have to have SOA RRs.

share|improve this answer

You need an A record for each server. (Using standard documentation data.)   A   A

You can then use CNAME records to point the server to the appropriate server. I split the hosts as per your addresses.    CNAME    CNAME  CNAME

On your servers use virtualhost definitions in your web server to define the available websites. There is no siginificant penalty for defining unused virtual hosts, so you could set up sites on several servers but only provide DNS records for one.

If you want to handle domains like which require more than one DNS record. You need to use A records. There are a couple of ways to do this. Have an A record with the same address as the host that serves the domain.         A         A       A

Another approach would be to use a server to redirect the domains to their www subdomains. This could be the same as one or more of the hosts above.        A        A      A

Seriously consider setting up MX records for the domains like Also consider SPF for both versions of the domain. If you mail server is these records should work (SPF records are optional an may not be accepted by old DNS servers.):        MX   10        TXT  'v=spf1 mx -all'        SPF  'v=spf1 mx -all'    TXT  'v=spf1 -all'    SPF  'v=spf1 -all'

The above SPF records state that only the MX will send email for the domain, and no mail should have the domain For domains that won't originate email remove the mx from the TXT and SPF records. See or my article on SPF for more detail.

Remember that domain data is cached. When moving static sites, leave the site up on the old host until traffic stops arriving. Moving sites with dynamic content is more difficult.

share|improve this answer
You can't have a CNAME at the zone apex as it cannot be used in conjunction with another RR type. As the SOA RR exists at the apex, you can't use a CNAME. – James O'Gorman Nov 4 '11 at 19:30
@James O'Gorman Yes SOA and NS records at a minium. I new there was a good arguement against no_www. This applies for any delegated domain. – BillThor Nov 4 '11 at 21:57

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.