CNAME What is a CNAME Record?

A CNAME record creates a hostname alias pointing to another hostname. Learn when to use CNAMEs, the zone apex limitation, and how ALIAS records work.

What is a CNAME record?

A CNAME (Canonical Name) record creates an alias from one hostname to another. Instead of pointing to an IP address directly, a CNAME points to a target hostname which is then resolved through its own DNS records.

CNAMEs are useful when you want multiple names to resolve to the same IP without duplicating A records everywhere — change the A record in one place and all CNAMEs update automatically.

Anatomy of a CNAME record

www.example.com.  3600  IN  CNAME  example.com.
FieldValueDescription
Namewww.example.com.The alias — the name being looked up.
TTL3600Time-to-live in seconds.
ClassINInternet class.
TypeCNAMERecord type.
Targetexample.com.The canonical name to resolve. The resolver then looks up this hostname's A/AAAA records.

Common uses

  • www subdomainwww.example.comexample.com so both resolve to the same server.
  • CDN aliases — Point assets.example.com to your CDN's domain (e.g. example.cdn.com) so CDN IP changes don't require DNS updates on your side.
  • SaaS service aliases — Many services ask you to add a CNAME to map your custom domain to their infrastructure (e.g. blog.example.comcustomer.ghost.io).

The zone apex restriction

A CNAME record cannot be placed at the zone apex (the root domain itself, e.g. example.com without www). This is a hard DNS specification limit. The reason: a zone apex must have SOA and NS records, and a CNAME cannot coexist with any other record type at the same name.

Some DNS providers offer a proprietary workaround called ALIAS, ANAME, or CNAME flattening. These appear as normal A/AAAA records to the outside world but behave like CNAMEs internally, allowing root domain aliasing.

CNAME chains

A CNAME can point to another CNAME, creating a chain. Resolvers follow the chain until they reach an A or AAAA record. Chains add latency — one extra DNS lookup per hop. Keep chains to a minimum (ideally zero).

Common mistakes

  • CNAME at the zone apex — Not allowed by RFC. Use ALIAS/ANAME or an A record instead.
  • CNAME coexisting with other records — A CNAME at a given name cannot share that name with any other record type. If you add a CNAME for mail.example.com, you can't also add an A record for it.
  • MX or NS pointing to a CNAME target — MX and NS records should not reference CNAME targets per RFC 2181. Use A records for mail and nameserver hostnames.

Frequently asked questions

Can a CNAME point to an IP address?

No. A CNAME must point to a hostname, not an IP address. Use an A record to point to an IP.

What is CNAME flattening?

CNAME flattening (also called ALIAS or ANAME depending on the DNS provider) is a proprietary feature that lets you use a CNAME-like alias at the root domain. The DNS provider resolves it server-side and returns A/AAAA records, staying within the DNS spec.

Does a CNAME affect TTL?

Both the CNAME record and its target A record have their own TTLs. The effective TTL for the resolved IP is the lower of the two.