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 2 domains: and I have 1 website (say served by IP is the preferable name, but I want to be usable as well.

I am not concerned about SEO at this point (but might be in the future).

What is the proper way to setup DNS, such that:

  • DNS handles requests for directly and refers to the website at
  • forwards all requests to

Can I simply create an A record in each zone that points to Or, is there any way to point at using only DNS?

share|improve this question
I am really digging the additional comments bringing to light the nuances of when each technique is best used. Thanks SOers. – condiosluzverde Sep 10 '10 at 14:50
up vote 2 down vote accepted

While it's certainly possible to create a CNAME for to point to, it's usually not recommended unless you can fully grasp the ramifications of doing so.

I'd just recommend creating two DNS A records, one for each domains, pointing to the same IP address. Then in your apache config, do something like this:

<VirtualHost *:80>

    DocumentRoot /path/to/root

Can I simply create an A record in each zone that points to

No, DNS records have nothing to do with TCP/UDP ports. Your application (a web browser in this case) will need to take care of that.

share|improve this answer
thanks for clarification, it's just late and I'm tired. I will edit out the :80 in reference to A record. – condiosluzverde Sep 9 '10 at 3:01
Can you briefly state the ramifications of using CNAME of domainB pointing to domainA? – condiosluzverde Sep 9 '10 at 3:04
@arrochar - Basically the CNAME follows the A record that it points at, so if you want to change where DomainA is and leave domainB, it requires reconfiguration of DNS entries which are cached across the Internet. – MDMarra Sep 9 '10 at 3:34
In addition to what MarkM stated, all records for will follow the CNAME, including any MX, PTR, etc. records. – EEAA Sep 9 '10 at 3:46
True and this can be good or bad. For example, if you have domainB only for backward compatibility needs or to address mispelling errors, the all records follow to domainA is what you need but if you have only a commom application on both domains and the rest is different, then CNAME is not the good way. – laurent Sep 9 '10 at 16:27

You can use an A record on each domain pointing to the same IP without problems but I prefer to create a CNAME record in domainb.hosts pointing to server name (not IP). A nslookup to will return you the IP and the cannonical name server name.

Web server have to handle both name. If Apache, you can use ServerName and ServerAlias

share|improve this answer

I'm not an dns expert, but I think you can create an cname to domainB appoint to domainA and config your http server, to respond to domainA and B in same website.

share|improve this answer

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.