Reference guide · dns-ssl · Published 2026-08-15 · 4 min read
CNAME vs A records
CNAME vs A records explained with lookup examples, apex rules, CNAME flattening, and a table to decide which record to create.
- ·What each resolves
- ·Apex problem
- ·Practical decision
Overview
An A record maps a name straight to an IPv4 address. A CNAME maps a name to another name, and that second name then resolves to an address through further lookups. The person who created the "A vs CNAME" choice did so because it hides the address behind a layer that the IP holder can change whenever it wants, and the two behave differently at the apex and under MX.
How each one resolves
For A: the answer is complete. www.example.com A 203.0.113.7 returns the IP immediately.
For CNAME: the answer is a chain. static.example.com CNAME cdn.example.net then asks the resolver for cdn.example.net, which may itself be another host records chain, until an A record ends it.
| Record | Answers with | Problem it solves |
| A | IPv4 directly | Simple, works everywhere, no extra lookup |
| CNAME | another hostname | Lets you point at a CDN or host whose IP may rotate, so you never hard-code an address |
That chain is why CNAMEs work well for CDN and managed-host edges, which rotate IPs often: you never hard-code an address that the provider will later change. Going the other way, an A record forces you to update the record whenever the server IP moves.
Why the apex is a problem
The apex, example.com, is special. Many DNS panel hosts forbid a CNAME at the apex because the DNS standard requires other records on that name (NS, SOA, sometimes MX) and a CNAME forbids any other records on the same name. As a result, example.com usually needs an A record while www.example.com may point to a CNAME.
Remember the chain can be shared: www.example.com CNAME example.com also works, though the simplest and most common layout is:
| Name | Type | Value |
|---|---|---|
| example.com | A | 203.0.113.7 |
| www.example.com | CNAME | example.com |
If your DNS provider supports "CNAME flattening" (it takes your CNAME-over-apex and resolves it at the edge before answering the client), you can write the alias at the apex too. Flattening is a provider feature, not part of the base DNS protocol, so confirm before you rely on it.
How to choose
- Need a fixed IP address (a single dedicated server, a hosting account with a static IP)? Use an A record.
- Want to point at an IP-rotating host, a CDN, a managed email host, or a hostname-only service? Use a CNAME.
- It is the apex and the provider does not flatten? Use the A record.
- Email senders for the domain (MX, SPF) point at hostnames, not at the apex A, so mail is unaffected by the A/CNAME choice on the apex.
Testing
The nslookup command shows the incoming response: nslookup www.example.com prints an address (or the CNAME then an address), which tells you whether you are looking at an alias. nslookup -type=CNAME at an authoritative server queries the raw record rather than the ended chain.
Check your assumptions
- An A record is IPv4 only; the IPv6 sibling is
AAAA. Dual-stacked hosts need both A and AAAA for the same name. - You cannot have both
CNAMEand another record of a different type on the same name; deliver that service on a subdomain and CNAME from there. - Use a CNAME for
wwwpointing at the hosted provider name (for exampleexample.com.cdn.cloudflare.net), and let propagation settle before you judge a migration.
The record types reference covers the wider record family; the TTL article explains how long those answers are cached.