0

I have 2 domains: domainA.com and domainB.com. I have 1 website (say served by IP xxx.xxx.xxx.xxx:80)

domainA.com is the preferable name, but I want domainB.com 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 domainA.com directly and refers to the website at xxx.xxx.xxx.xxx:80
  • domainB.com forwards all requests to domainA.com

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

1
  • I am really digging the additional comments bringing to light the nuances of when each technique is best used. Thanks SOers.
    – qxotk
    Sep 10, 2010 at 14:50

3 Answers 3

2

While it's certainly possible to create a CNAME for domainB.com to point to domainA.com, 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>
    ServerName domainA.com
    ServerAlias domainB.com

    DocumentRoot /path/to/root
    ...
</VirtualHost>

Can I simply create an A record in each zone that points to xxx.xxx.xxx.xxx:80?

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.

5
  • thanks for clarification, it's just late and I'm tired. I will edit out the :80 in reference to A record.
    – qxotk
    Sep 9, 2010 at 3:01
  • Can you briefly state the ramifications of using CNAME of domainB pointing to domainA?
    – qxotk
    Sep 9, 2010 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, 2010 at 3:34
  • 1
    In addition to what MarkM stated, all records for domainB.com will follow the CNAME, including any MX, PTR, etc. records.
    – EEAA
    Sep 9, 2010 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, 2010 at 16:27
1

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 domainA.com server name (not IP). A nslookup to domainB.com will return you the IP and the cannonical name domainA.com server name.

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

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .