A CNAME (canonical name) record says "this name is really that other name". Instead of storing an IP address, it points one hostname at another, and the resolver follows the second name to find the address. It is how you connect subdomains to services that may change their servers without telling you.
How a CNAME is resolved
Say shop.example.com has a CNAME pointing to stores.shopprovider.com. A resolver asking for shop.example.com receives the alias, then looks up stores.shopprovider.com and returns that name's IP address. If the provider moves to new servers, it updates its own record and your CNAME keeps working with no change on your side. That is the main advantage over an A record, which hard-codes one IP.
The rules a CNAME must follow
- It cannot sit alongside other records with the same name. A name with a CNAME may not also have an MX, TXT or A record.
- So it cannot be used on the bare domain. The root,
example.com, always has NS and SOA records, so a standard CNAME there is not allowed. - It points to a hostname, never an IP.
Some DNS providers work around the root limitation with features called CNAME flattening (Cloudflare) or ALIAS / ANAME records. They follow the alias themselves and serve a plain A record to visitors, which is useful when a host only gives you a hostname.
Example: connecting a booking tool
A physiotherapy clinic uses an online booking service. The service asks the clinic to add a CNAME with the name book and the value clinic-name.bookingservice.com. Once saved, book.clinicname.com shows the booking pages under the clinic's own address, and the service issues an SSL certificate for that name. Email security setups use CNAMEs in a similar way, for example to delegate DKIM keys to an email provider.
When you will meet CNAMEs
Almost every hosted tool that offers a "custom domain" asks for one. It is also the usual way to set up www. If you only ever connect your main domain to one host, you may just use A records instead.
CNAME mistakes
- Adding a CNAME where an MX already exists. The panel may refuse, or one record silently overrides the other.
- Chaining aliases. A CNAME pointing at another CNAME works but adds lookups and more places to break.
- Forgetting the trailing details. Copy the target hostname exactly, including any unusual prefix the provider gives you.
- Leaving orphaned CNAMEs. One pointing at a cancelled service can be claimed by someone else, a takeover risk covered under subdomains.
Related terms
- DNS records: CNAME compared with A, MX and TXT.
- Subdomain: the names CNAMEs are most often placed on.
- MX record: a record type that cannot share a name with a CNAME.
- TTL: controls how long the alias is cached.