What it is
An A record maps a name to an IPv4 address. A CNAME record maps a name to another name, and the resolver then looks that name up to find the addresses. Use an A record when you control a stable IP; use a CNAME when someone else (a CDN, a SaaS platform, a load balancer) gives you a hostname whose addresses they manage.
example.com. 3600 IN A 203.0.113.10
www.example.com. 3600 IN CNAME example.com.
shop.example.com. 3600 IN CNAME shops.myshopify.com.
How they differ
| A record | CNAME record | |
|---|---|---|
| Points to | An IPv4 address (AAAA for IPv6) | Another hostname |
| Defined in | RFC 1035 | RFC 1034 |
| At the zone apex | Yes | No: the apex has SOA and NS, and a CNAME can't share a name with other records |
| Alongside MX, TXT at the same name | Yes | No, the CNAME must be alone |
| Several at one name | Yes, for round-robin | Only one |
| When the target's IP changes | You update it | Nothing to do |
| Extra lookup | No | Yes, though resolvers usually return the chain in one response |
A CNAME aliases the whole name for every record type: asking for the MX or TXT of a CNAME name returns the target's records. That's why it can't coexist with other records. MX and NS records must also never point at a name that is a CNAME (RFC 2181).
Common setups
- GitHub Pages:
wwwis a CNAME to<user>.github.io; the apex uses four A records (185.199.108.153to185.199.111.153). - Vercel: subdomains are a CNAME to
cname.vercel-dns.com, the apex an A record. - Shopify:
wwwis a CNAME toshops.myshopify.com, the apex an A record to23.227.38.65. - Cloudflare: lets you create a CNAME at the apex and flattens it into A records (ALIAS-style).
The pattern is the same everywhere: CNAME where you can, A (or ALIAS) at the apex.
How to check it
Look up the name in our DNS Lookup, then the target's A records. With dig, a CNAME shows up in the answer before the addresses:
dig www.example.com A +noall +answer
dig www.example.com CNAME +short
nslookup www.example.com
nslookup lists a CNAME as "Aliases". If dig ... CNAME +short prints nothing, the name has A records of its own (or nothing).
Common mistakes
- A CNAME at the apex: most providers reject it, and where accepted it breaks mail and verification records.
- A CNAME at a name that also needs a TXT (domain verification) or MX: move the TXT elsewhere or use A records.
- Pointing a CNAME at an IP address: the value must be a hostname.
- A hard-coded A record for a CDN or platform whose IPs change; the site breaks when they do.
- Forgetting the trailing dot in raw zone files, which turns
example.comintoexample.com.example.com.
Related record types
- ALIAS record: a CNAME-like answer at the apex.
- AAAA record: the IPv6 counterpart of the A record.
- DNS TTL: CNAME chains are cached per link.