CNAME record
Learn what a DNS CNAME record is, how it creates domain aliases, key limitations (especially for root domains), lookup methods, best practices, and troubleshooting.
TL;DR
A CNAME record (Canonical Name) creates an alias, it points one domain name to another domain name (not directly to an IP).
DNS resolvers follow the CNAME to the target domain and resolve its A or AAAA record.
This is ideal for subdomains (e.g. www → root domain, or CDN endpoints), but cannot be used at the root domain if other records (MX, TXT, etc.) exist.
When a resolver sees a CNAME:
CNAMEs are great when the target IP might change (e.g. CDN, hosted service), update the target's A record once, and all aliases follow.
www.example.com → example.comcdn.example.com → CloudFront / Akamai endpointblog.example.com → WordPress.com, GitHub Pages, etc.dig www.example.com CNAMEnslookup -type=CNAME www.example.comNAME TTL CLASS TYPE VALUE
www.example.com. 3600 IN CNAME example.com.Classic www alias
www.example.com. CNAME example.com.
example.com. A 192.0.2.1CDN example
cdn.example.com. CNAME d1234567890.cloudfront.net.GitHub Pages / hosted service
blog.example.com. CNAME username.github.io.Multiple subdomains
api.example.com. CNAME api.backend-service.net.
shop.example.com. CNAME shops.myshopify.com.| Feature | CNAME | A / AAAA |
|---|---|---|
| Points to | Domain name | IP address |
| Extra DNS lookup | Yes (adds latency) | No |
| Allowed at root | No (if other records exist) | Yes |
| Multiple per name | No (only one CNAME) | Yes |
| Other records allowed | No | Yes |
| Best for | Changing targets (CDN, hosting) | Static/performance-critical |
→ See also: A Record, AAAA Record
Related: A Record · AAAA Record · DNS Basics