A CNAME record (Canonical Name record) creates an alias — it points one domain name to another domain name. DNS then resolves the target domain to find the final IP address. This indirection makes CNAME records highly flexible for managing third-party services and subdomains.
How CNAME Works
www.example.com IN CNAME example.com
shop.example.com IN CNAME example.myshopify.com
When a browser looks up www.example.com, DNS follows the CNAME chain: www.example.com → example.com → A record → IP address.
When to Use CNAME
- www subdomain → aliased to the root domain
- Third-party services →
shop.example.com→ Shopify,help.example.com→ Zendesk - CDN configuration →
assets.example.com→ your CDN hostname - Service verification → some services require a CNAME to verify domain ownership
CNAME Restrictions
- Cannot be used on the root domain —
example.comcannot be a CNAME (RFC 1912). Use ALIAS/ANAME records if your DNS provider supports them. - Cannot coexist with other records — A CNAME on a name cannot share that name with MX, NS or other records.
- Avoid deep chains — CNAME → CNAME → CNAME adds latency and hits resolver limits.
CNAME vs A Record
- Use A record when you have a fixed IP to point to directly.
- Use CNAME when pointing to a hostname (especially third-party services where the IP may change).