CNAME record: what it is and how to check it

Makes one name an alias of another, so it follows the target's addresses automatically.

Check with the CNAME Checker

What it is

A CNAME record (canonical name) says that one name is an alias of another. For example, www.example.com can be an alias of example.com, or shop.example.com can be an alias of stores.example.net, a name managed by an e-commerce platform.

When a resolver looks up a name that has a CNAME, it restarts the lookup with the target name and returns the target’s records. The alias therefore always follows the target: if the platform changes its IP addresses, your alias keeps working without any change on your side. CNAME is defined in RFC 1034 and RFC 1035.

How it works

Suppose a browser needs the address of shop.example.com:

  1. The resolver asks for the A record of shop.example.com.
  2. The authoritative server for example.com answers: “shop.example.com is a CNAME for stores.example.net”.
  3. The resolver now looks up the A record of stores.example.net and gets 203.0.113.40.
  4. The final answer contains both the CNAME and the A record, so the client sees the whole chain.

The same happens for any record type except CNAME itself: ask for AAAA, MX or TXT on an alias and you receive the target’s records of that type.

The key rule, from RFC 1034 section 3.6.2, is that a name with a CNAME cannot have any other data. That is why you cannot place a CNAME at the zone apex, which always holds SOA and NS records, and why you cannot add an MX or TXT record next to a CNAME. The only exception is DNSSEC records (RRSIG and NSEC), which protect the CNAME itself.

When to use a CNAME

A CNAME is the right choice when someone else controls the addresses behind a name:

  • pointing www, shop or docs to a hosting, e-commerce or documentation platform;
  • connecting a subdomain to a CDN, which changes its edge addresses often;
  • delegating a DKIM key to your email provider, so the provider can rotate it without asking you.

When you control the server yourself and its address rarely changes, plain A and AAAA records are simpler and save a lookup.

Syntax and fields

Field Example Meaning
Name www.example.com. The alias.
TTL 3600 Cache lifetime of the alias itself.
Class IN Internet.
Type CNAME The record type.
Data example.com. The canonical (target) name. Only one CNAME per name.

The target is a host name, never an IP address and never a URL. Write it as a fully qualified name with a trailing dot in zone files; without the dot, many tools append the zone name, turning example.net into example.net.example.com..

The alias and the target have separate TTLs. A resolver caches the CNAME for its own TTL and the target’s records for theirs.

Examples

www as an alias of the apex:

example.com.        3600  IN  A      192.0.2.10
www.example.com.    3600  IN  CNAME  example.com.

A subdomain pointing to a hosted service:

shop.example.com.   3600  IN  CNAME  stores.example.net.

A two-hop chain, as often created by CDNs:

static.example.com.       300  IN  CNAME  example.cdn.example.net.
example.cdn.example.net.  60   IN  CNAME  edge7.cdn.example.net.
edge7.cdn.example.net.    60   IN  A      198.51.100.77

Invalid: a CNAME next to another record on the same name.

; wrong: mail.example.com cannot have both
mail.example.com.   3600  IN  CNAME  mailhost.example.net.
mail.example.com.   3600  IN  TXT    "v=spf1 -all"

Common mistakes

  • CNAME at the apex. Use A and AAAA records, or your provider’s flattening or ALIAS feature, for example.com itself.
  • CNAME next to other records. Verification TXT records, MX records and CNAMEs must live on different names. If a service asks you to add a TXT on a name that already has a CNAME, the setup needs rethinking.
  • Missing trailing dot. stores.example.net without the dot may become stores.example.net.example.com. in a zone file.
  • Pointing to a target that does not exist. A CNAME to a deleted service returns NXDOMAIN. Worse, a dangling CNAME to a cloud resource you no longer own can let someone else claim that resource and serve content on your subdomain (subdomain takeover). Remove CNAMEs when you cancel a service.
  • Loops. a.example.com pointing to b.example.com pointing back to a.example.com makes resolution fail with SERVFAIL.
  • MX or NS pointing to an alias. Point them to names with real address records.

How to check it

The CNAME checker follows the whole chain, up to 10 hops, and shows each alias with its TTL, the final records at the end, and a warning if it detects a loop. It is the quickest way to confirm that a CDN or SaaS hostname is set up the way the provider expects.

For a single step, use the DNS lookup tool with type CNAME. To see whether a recent change has reached the public resolvers, use the DNS propagation checker.

  • A and AAAA: the address records usually found at the end of a chain.
  • HTTPS / SVCB: a newer way to point a name, including the apex, to a service using AliasMode.
  • MX and NS: must never point to a CNAME.

Frequently asked questions

Why can't I put a CNAME on my bare domain?

The zone apex (example.com itself) must have SOA and NS records, and a CNAME cannot coexist with any other record on the same name. Some DNS providers offer 'CNAME flattening' or ALIAS/ANAME records, which resolve the target on their side and publish ordinary A and AAAA records at the apex. These are provider features, not a standard record type.

Can a CNAME point to another CNAME?

Yes, and resolvers will follow the chain. Each hop adds a lookup, though, and long chains are fragile. Keep chains short, ideally one hop, and never create a loop.

Can an MX or NS record point to a CNAME?

No. RFC 2181 (section 10.3) says MX and NS targets must be names with address records, not aliases. Many mail servers tolerate it, but some reject it, so always point MX and NS to names with A or AAAA records.

Does a CNAME redirect visitors to another website?

No. A CNAME only changes which addresses the browser connects to. The address bar keeps showing the original name, and the server must be configured to accept that name, including a TLS certificate that covers it.