Why can't a domain's root be a CNAME? [duplicate]
Firstly, the underlying reason is not that you must use an A record, but that you cannot use a CNAME record because those cannot coexist with other normal resource record types.
The reason for that restriction is in §3.6.2 of RFC 1034:
If a CNAME RR is present at a node, no other data should be present; this ensures that the data for a canonical name and its aliases cannot be different. This rule also insures that a cached CNAME can be used without checking with an authoritative server for other RR types.
As the root of a (delegated) domain must have an SOA and NS records the rule above kicks in, preventing use of CNAMEs too.
Well it's not that the root of a domain can't be a CNAME
- It's that a CNAME
cannot coexist with other record types for the same domain.
Simply put, it would make no sense for a domain with a CNAME
to have any other record type, because the CNAME
would ensure that they would never be seen or read.
Let's say we did try to give example.net
both a CNAME
(pointing to host.example.com) and an A
record (pointing to some other IP address).
First, the client would request an
A
record fromexample.net
from example.net's nameservers.example.net's nameservers would inform us that we need to follow a
CNAME
record in order to proceed. So we do. TheCNAME
points tohost.example.com
.The client would request an
A
record fromhost.example.com
's nameservers.
Notice how we never got the chance to read an A
record, or any other record type, from example.net? The CNAME
takes precedence.