Contents
7 sections · 6 min read
Diagram showing CNAME record aliasing subdomain to canonical domain name
Domain Management

What Is a CNAME Record? How DNS Aliases Work and When to Use Them

A
Domain 360 Team
·July 13, 2026·6 min read

A CNAME record is a DNS alias. It maps one domain name to another domain name — telling DNS resolvers: for this name, look up that name instead. The resolver follows the alias, resolves the target to an IP address, and returns the final result.

How CNAME Resolution Works

When a browser looks up www.example.com and finds a CNAME pointing to example.com, the resolver does not stop there. It fetches the canonical target (example.com), resolves that to an IP address, and returns the final IP. The browser connects to the IP.

This indirection is the point. When example.com's A record changes (server migration), www.example.com automatically follows — no additional DNS edits required.

Real CNAME Examples

www.yourdomain.com → yourdomain.com (www visitors reach the same server as non-www visitors)

blog.yourdomain.com → yoursite.wordpress.com (branded subdomain pointing to a hosted blog platform)

api.yourdomain.com → your-app.herokuapp.com (stable branded URL that survives moving hosting providers)

abc123.yourdomain.com → verify.someservice.com (domain ownership verification for a third-party service)

CNAME vs A Record

A record: Maps a name directly to an IP address. Required for root domains. CNAME: Aliases one name to another name. Used when the target's IP may change.

| Situation | Use | |---|---| | Root domain (yourdomain.com) | A record | | Subdomain to external service | CNAME | | Name where IP may change | CNAME | | Name needing MX or TXT records | A record |

The Root Domain Limitation

You cannot set a CNAME on the apex domain (yourdomain.com without any subdomain). DNS prohibits this because root domains need other record types — particularly MX records for email — and CNAME's exclusivity rule means no other records can coexist at the same hostname.

Workarounds: Cloudflare CNAME Flattening resolves the CNAME chain at the root and returns the final IP, bypassing the prohibition. Some DNS providers offer ALIAS or ANAME records that work like CNAMEs at the root.

CNAME Exclusivity

If you set a CNAME for a hostname, you cannot set any other record type for that exact hostname — no A, MX, TXT, or anything else. This is why CNAMEs cannot be used at the root domain where email (MX records) is needed.

Checking Your CNAME Records

dig yourdomain.com cname or: nslookup -type=cname www.yourdomain.com

If the result shows the canonical name followed by an A record with an IP, the chain resolves correctly. The DNS lookup commands guide covers reading these results in full.

CNAME Chains

A CNAME can point to another CNAME. Chains of 2-3 are usually fine. Chains of 4+ add latency and some resolvers refuse to follow beyond a certain depth. Avoid chains where possible — point CNAMEs directly to A records.

CNAME records depend on the root domain remaining registered. An expired domain stops all DNS resolution — every CNAME alias pointing through it fails. Tracking domain expiry with a domain management dashboard keeps the DNS chain working.

Never lose a domain again

Track every domain you own in one dashboard. Free for up to 15 domains.