What is a CNAME record?

A CNAME record makes one hostname an alias of another: the resolver restarts the lookup with the target name and uses whatever records it finds there.

CNAME stands for canonical name. If www.example.com is a CNAME for example.com, a resolver asked for the address of www.example.com follows the alias and returns the A and AAAA records of example.com. This is convenient when a third party hosts the service: you point a name at the provider's hostname and the provider can change the underlying addresses without you touching your zone.

The important restriction is that a name with a CNAME cannot have any other record. That is why a CNAME cannot be placed at the apex of a zone (example.com itself), which must carry SOA and NS records. DNS providers work around this with proprietary "ALIAS", "ANAME" or "CNAME flattening" features that resolve the target on their side and answer with plain A and AAAA records.

A CNAME points to a name, never to an IP address, and it should not point to another long chain of CNAMEs: every hop costs an extra lookup. MX and NS records must not point at a name that is itself a CNAME.

Example

www.example.com.   3600  IN  CNAME  example.com.
shop.example.com.  3600  IN  CNAME  stores.platform.example.

Check it

See how CNAME record looks for a real domain:

DNS lookup