Knowledge base

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.

What Is a CNAME Record in DNS?

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.

Look up CNAME records
Enter a domain name to lookup CNAME records

Enter the domain name you want to lookup

How CNAME Records Work

When a resolver sees a CNAME:

  1. It stops looking for other records at that name.
  2. It queries the target domain instead.
  3. It continues until it finds an A/AAAA record (or another CNAME, but avoid long chains).

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.

Common Use Cases

  • www alias: www.example.comexample.com
  • CDN integration: cdn.example.com → CloudFront / Akamai endpoint
  • Third-party services: blog.example.com → WordPress.com, GitHub Pages, etc.
  • Subdomain redirects: Alias subdomains to different providers without duplicating IPs
  • Easier migrations: Change one target instead of many A records

How to Lookup CNAME Records

dig www.example.com CNAME
nslookup -type=CNAME www.example.com

Record Format

NAME                TTL    CLASS  TYPE   VALUE
www.example.com.    3600   IN     CNAME  example.com.
  • VALUE: Must be another domain name (FQDN with trailing dot recommended)
  • Only one CNAME per name allowed
  • No other records (A, MX, TXT, etc.) can exist at the same name

Valid Examples

Classic www alias

www.example.com.  CNAME  example.com.
example.com.      A      192.0.2.1

CDN 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.

CNAME vs A / AAAA Records

FeatureCNAMEA / AAAA
Points toDomain nameIP address
Extra DNS lookupYes (adds latency)No
Allowed at rootNo (if other records exist)Yes
Multiple per nameNo (only one CNAME)Yes
Other records allowedNoYes
Best forChanging targets (CDN, hosting)Static/performance-critical

→ See also: A Record, AAAA Record

Frequently Asked Questions

Can I use CNAME at the root domain (example.com)?
No, not if you have MX, TXT, NS, or other records. Use A/AAAA instead. Some providers offer "CNAME flattening" / ALIAS records as a workaround.
Can a CNAME point to another CNAME?
Yes, but avoid it, chains increase latency and failure points.
What's better: CNAME or A record?
Use A/AAAA for speed and root domains.
Use CNAME for flexibility when the target might change (CDN, SaaS).
Can I have CNAME and other records at the same name?
No, DNS forbids it. If a CNAME exists, no other types (A, MX, etc.) can coexist at that exact name.

References

Related: A Record · AAAA Record · DNS Basics