DNS CNAME Record: Aliases & Rules Explained

Jul 13, 2026
Updated Jul 13, 2026 DNS Records dns cname record cname record cname vs a record cname flattening

A DNS CNAME (Canonical Name) record makes one hostname an alias of another. Instead of pointing at an IP address like an A record, a CNAME points at another domain name, and the resolver then continues resolving that name to find the real address. CNAMEs are how www.example.com can quietly follow whatever example.com points to.

What is a CNAME record?

Defined in RFC 1035, a CNAME creates an alias from one name (the alias) to another (the canonical name). When a resolver hits a CNAME, it restarts the lookup on the target name, following the chain until it reaches an A or AAAA record. This is useful when several hostnames should always track a single canonical target — change the target once and every alias follows.

CNAME record structure and example

www.example.com.    3600   IN   CNAME   example.com.
blog.example.com.   3600   IN   CNAME   hosting-provider.net.
FieldMeaning
Alias nameThe hostname being aliased (www.example.com).
TypeAlways CNAME.
Canonical nameThe target hostname the alias resolves to. It must be a name, never an IP address.

CNAME rules and restrictions

CNAMEs have two rules that trip people up:

  • A CNAME cannot coexist with other records for the same name. If www.example.com has a CNAME, it cannot also have an A, MX, or TXT record. The alias must stand alone.
  • A CNAME cannot sit at the zone apex. The root of a domain (example.com with no subdomain) must carry a SOA and NS records, and those cannot coexist with a CNAME. To alias the apex, providers offer non-standard workarounds branded as CNAME flattening, ALIAS, or ANAME records.

How to check a CNAME record

# dig (Linux/macOS)
dig www.example.com CNAME +short

# nslookup
nslookup -type=CNAME www.example.com

To trace an alias to its final address and see the full record set for a domain, use the free DNS lookup tool.

CNAME vs A record

An A record is the final answer — a name pointing straight to an IPv4 address. A CNAME is a redirection — a name pointing to another name that still has to be resolved. Every CNAME chain ultimately ends at an A or AAAA record. Because a CNAME adds an extra lookup, use A/AAAA records for the destination itself and reserve CNAMEs for aliases that should track it.

Common CNAME problems

  • CNAME at the apex. Adding a CNAME to the bare domain breaks the required SOA/NS records. Use CNAME flattening or an A record instead.
  • CNAME plus other records. Pairing a CNAME with an MX or TXT on the same name is invalid and produces unpredictable results.
  • Long or looping chains. Chaining CNAME to CNAME to CNAME adds latency; a chain that points back on itself never resolves.

Related DNS records

CNAMEs work alongside the address records they ultimately reach — A and AAAA — and the apex records they cannot replace, SOA and NS.

Frequently asked questions

Can I use a CNAME on my root domain?

Not with a standard CNAME — the apex needs SOA and NS records that a CNAME cannot coexist with. Use your provider's CNAME flattening / ALIAS / ANAME feature, or an A record, for the root.

What is the difference between a CNAME and an A record?

An A record maps a name to an IPv4 address (the final answer). A CNAME maps a name to another name (an alias) that still needs resolving.

Can a CNAME point to an IP address?

No. A CNAME's target must be a hostname. To point at an IP, use an A (IPv4) or AAAA (IPv6) record.

Scan for these vulnerabilities

Secably automatically detects the issues discussed in this article.

Start Free Scan