Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

What Each Record Holds

example.com.        3600  IN  A      203.0.113.10
www.example.com.    3600  IN  CNAME  example.com.
shop.example.com.   3600  IN  CNAME  stores.example.net.

The A record answers with an address. The CNAME, canonical name, answers "this name is an alias; ask for that one instead", and the resolver follows the chain until it reaches an A or AAAA record. AAAA is the IPv6 counterpart of A. The other record types are covered in DNS record types.

Side by Side

A recordCNAME
Points toAn IPv4 addressAnother name
Allowed at the apexYesNo
Other records beside itYesNo
Extra lookupNoSometimes
Follows target changesNoYes

No CNAME at the Zone Apex

The apex is the bare domain, example.com itself. It always carries SOA and NS records, and the DNS standard does not allow a CNAME to share a name with any other record. So the apex cannot be a CNAME: example.com needs an A record, and AAAA if you use IPv6. Most DNS hosts refuse to save an apex CNAME; where one is accepted anyway, mail and delegation for the domain can break.

A CNAME Stands Alone

The same rule applies to every name. If www is a CNAME, it can have no MX, TXT, or A record of its own. A common trap is adding a TXT record for domain verification to a name that is already a CNAME: the DNS host refuses it, or resolvers never see it. Also, MX and NS records must name a host that has its own A or AAAA record, never a CNAME.

The Extra Lookup

When a CNAME points into another domain, a resolver with an empty cache may need one more query to get the address. Resolvers cache both records, so on a busy name the delay is rarely noticeable. Chains of CNAMEs pointing to more CNAMEs add up, though; keep it to one step where you can. Each record in the chain has its own TTL.

ALIAS Records and CNAME Flattening

To point a bare domain at a service that only gives you a host name, some DNS hosts offer a record called ALIAS or ANAME, or CNAME flattening, as Cloudflare calls it. The DNS host looks up the target itself and answers with the resulting addresses as A and AAAA records, so the apex rule is kept. It is a feature of the DNS host, not a standard record type, and works only while your zone is hosted there.

When to Use Which

NameUse
Bare domainA and AAAA, or ALIAS
wwwCNAME to the bare domain, or A
Your own serverA
CDN or hosted serviceCNAME to the name they give
Mail host in an MX recordA

With www as a CNAME of the bare domain, you change the address in one place when the server moves. A CDN or hosted service gives you its own name as the CNAME target, so it can change its addresses without asking you.

Check with dig

dig +short example.com A
dig +short www.example.com

For a CNAME, the short output prints the chain, normally the target name first and then the address. To see the record type and TTL as well:

dig www.example.com +noall +answer

The dig command guide covers the other options. After a change, resolvers may keep the old answer until its TTL runs out; see DNS propagation.

Was this answer helpful?
Loading...