CNAME Record
A CNAME (Canonical Name) record maps an alias domain name to a different, canonical domain name. The DNS resolver follows the CNAME target and returns whatever records exist at the canonical name.
How CNAME Records Work
When a resolver queries a name that has a CNAME record, it does not get an IP address directly. Instead, it gets the canonical name and must perform a second lookup to resolve that name to an address. This creates a lookup chain.
blog.example.com. CNAME example.github.io.
example.github.io. A 185.199.108.153
In this example, a query for blog.example.com returns the CNAME pointing to example.github.io. The resolver then queries for the A record of example.github.io and returns that IP to the client.
When to Use a CNAME
- Subdomains pointing to hosting providers such as GitHub Pages, Netlify, or Vercel. The provider controls the IP, and a CNAME lets them change it without requiring updates on your side.
- CDN configuration where your subdomain needs to resolve to a CDN-provided hostname like
d1234.cloudfront.net.
- SaaS custom domains where the vendor asks you to CNAME a subdomain to their platform for verification and routing.
Restrictions
- Cannot exist at the zone apex. RFC 1034 prohibits a CNAME at the root of a zone (e.g.,
example.com) because a CNAME cannot coexist with SOA and NS records, which must exist at the apex. Some providers offer proprietary workarounds like ALIAS or ANAME records.
- Cannot coexist with other record types. If a name has a CNAME, it must not have any other records (A, MX, TXT, etc.) at the same name. This is the most commonly violated rule.
- Adds lookup latency. Each CNAME introduces an extra DNS resolution step. In practice, most resolvers handle this quickly, but chaining multiple CNAMEs compounds the delay.
Common Mistakes
- CNAME at the apex. Setting
example.com CNAME provider.com breaks DNS for the entire zone because it conflicts with SOA and NS records. Use an A record or your provider's ALIAS/ANAME feature instead.
- CNAME chains. Pointing a CNAME to another CNAME that points to yet another CNAME creates fragile, slow resolution paths. Keep chains to a single hop.
- MX alongside CNAME. Adding an MX record at a name that already has a CNAME is invalid. Mail delivery will fail unpredictably because resolvers may return either the CNAME or the MX depending on implementation.
Look up CNAME records with the DNS tool →