CNAME not resolving
Solution 1
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
Solution 2
You cannot use a CNAME for the root record in a zone file (this is prohibited per RFC 1034, read section 3.6.2). You'll need to put in an A record instead that points to the same IP as the target of your CNAME rule.
Related videos on Youtube
cori
Updated on September 18, 2022Comments
-
cori over 1 year
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?
-
John Gardeniers over 11 yearsWork backwards a little. First ensure the A record that your CNAME points to works first. Fix that and your CNAME should also work.
-
-
Jens over 11 yearsIf some changes came through, all of them should have come through. I'm not sure about the need for an A record. My mistake with a CNAME record was the missing tailing ".". So
@ IN CNAME example.blogs.com.
. But the SERVFAIL does not seem right (as well as "REFUSED"). The SERVFAIL problem is mentiond [here](www.linuxquestions.org/questions/linux-server-73/bind9-dig-x-returns-status-servfail-643191/c), the REFUSED problems also points to wrong configuration of the nameserver. As if you were not allowed to query. -
cori over 11 yearsI should have been more explicit; I'm using Linode's nameservers (ns[1-4].linode.com) and their DNS manager. Their servers are running, the zone files pass a check and have the trailing "." Moreover, when I do add an 'A' record for example.com, nslookup finds it within 15 minutes. Of course then example.com is pointed to blogs.com, not example.blogs.com.
-
cori over 11 yearsvery cogent explanation of what's going on; thanks!