What a CNAME record is
A CNAME record says "this name is another name for that one". The resolver then looks up the target name instead. It is how you point shop.example.com at a hosted service without knowing the service's IP addresses.
www.example.com. 3600 IN CNAME example.netlify.app.
When the service changes its addresses, your record keeps working, because it holds the name and not the address.
The two CNAME rules
- A CNAME must be alone. A name with a CNAME may hold no other record: no A, no MX, no TXT.
- No CNAME at the root. The root name (
example.comwith nothing in front) always has SOA and NS records, so by rule 1 it cannot have a CNAME.
To point a root domain at a hosted service, use the provider's ALIAS, ANAME or "CNAME flattening" feature. The provider looks up the target for you and answers with plain A records.
Common CNAME mistakes
- A dangling CNAME. The record points at a service you no longer use. Someone else can claim that name on the service and serve content on your subdomain. Delete records for services you have left.
- A CNAME on a name that receives mail. The MX record cannot sit beside it, so mail to that name breaks.
- A long chain. A CNAME pointing to a CNAME pointing to a CNAME costs a lookup each time. Point at the final name.