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?
While it's certainly possible to create a
CNAME
fordomainB.com
to point todomainA.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: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.
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
andServerAlias www.domainB.com
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.