Friday, October 31, 2014

domain name system - CNAME not resolving



I've got a domain (example.com) registered with godaddy and pointed to nameservers hosted by linode. I've got a multisite WordPress install on linode (blogs.com) and I want to point the domain to a subdomain of the wordpress install (example.com -> example.blogs.com).



The subdomain of the wordpress install works fine - DNS can find it and I can browse to it. in the linode's DNS manager I've set up a CNAME to make the pointer I referenced above.



Whois shows that the linode nameservers are set for the domain, but DNS can't find any nameserver for example.com.




Am I missing a step, or do I have something misconfigured?



EDIT 1



The answer section of the dig request using one of linode's nameservers is



;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 44359
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0



The answer section from the dig using my host's nameserver is



;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 16379
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0


Same response in the status field if I specify CNAME or just accept the standard A query.



I do not have an A record for that example.com on the linode nameservers; do I need to set that up?




This is a fairly recent change - a few hours ago, so maybe I'm just being impatient? The nameserver changes made at the same time came through pretty quickly. I figured that the CNAME entry would be simultaneous with that; am I wrong in that expectation?


Answer



Technically what you're asking for is invalid. CNAME conflicts with all other records (with a special exception for DNSSEC records), thus having CNAME xxxxx conflicts with the SOA, MX, NS etc records for the domain. My guess is that the reason the domain resolves when you use an A there and fails when you use CNAME is because the DNS server enforces those restrictions and is unable to process your zone file.



Furthermore, based on your response to @xwincftwx's question, it's not clear that getting CNAME to work would do what you want in the first place. A CNAME pointing to an A record is exactly the same as an A record in the first place. The CNAME is handled entirely internally by the DNS system and the web browser only sees the IP address. In your test with an A record (let's say 1.2.3.4), the browser connected to 1.2.3.4 and asked it for the website example.com. If that server isn't configured to serve a website for example.com it typically serves a default site (in this case blogs.com).



If you got your domain to work as a CNAME, the browser would ask for the IP address of example.com. DNS would see that it is a CNAME, look up example.blogs.com and return 1.2.3.4. The browser would connect to 1.2.3.4 and ask it for example.com just as it did when it was an A record.



If you want people going to example.com to be redirected to example.blogs.com then you'll need to set up a basic web server that receives connections to example.com and sends a 301 permanent redirect to the browser to tell it go to example.blogs.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...