DNS GUIDE

CNAME Lookup: How DNS Aliases Work and When to Use Them

Guide to CNAME records: how they work, their limitations, resolution chains, and best practices for configuration.

CNAME: aliases in the DNS world

A CNAME (Canonical Name) record is a type of DNS record that creates an alias from one hostname to another. Instead of pointing directly to an IP address (like an A record does), a CNAME says "this name is actually an alias for this other name — go look up the IP there". It's like mail forwarding: if you send a letter to "5 Rome Street" and there's a sign saying "the tenant has moved to 10 Milan Street", the mail is delivered to the new address.

CNAMEs are fundamental in modern web infrastructure: almost all cloud services, CDNs, and SaaS platforms require configuring a CNAME that points to their hostname. When you use Cloudflare, AWS, Heroku, GitHub Pages, or any other cloud service, your domain typically has a CNAME pointing to the provider's hostname. This allows the provider to change their server IPs without requiring changes to your DNS.

The CNAME rules you need to know

CNAME records have strict rules defined in the RFCs that, if violated, cause resolution errors. The most important rule: a hostname with a CNAME record cannot have any other type of record. This means that if www.example.com has a CNAME, you cannot add a TXT, MX, or any other record on the same hostname. This limitation exists because the CNAME indicates that name is an alias — all DNS queries for that name are redirected to the CNAME target.

The second critical rule: you cannot use a CNAME on the root (apex) of the domain. The domain example.com (without www) must have at least SOA and NS records, which cannot coexist with a CNAME. If your cloud service requires a CNAME but you need to use the domain root, look for alternatives in your DNS provider: ALIAS, ANAME, or CNAME flattening that resolve the conflict server-side.

CNAME chain and resolution
$ cname-lookup --host shop.esempio.com

shop.esempio.com
  └─ CNAME → shops.myshopify.com
       └─ CNAME → shops.shopify.com
            └─ A → 23.227.38.65

Catena completa: 2 livelli CNAME → IP finale

CNAME chains and performance

When a CNAME points to another hostname that is itself a CNAME, a chain is created. Our CNAME Lookup follows the entire chain to the final resolution, showing each level. CNAME chains add latency: each level requires an additional DNS query. The best practice is to limit chains to 1-2 levels. Longer chains are usually the result of legacy configurations layered over time and should be simplified.

An insidious problem with CNAME chains is loops: A points to B which points back to A. This causes an infinite resolution error that resolvers terminate after a maximum number of steps (typically 8-10). The CNAME Lookup identifies loops by clearly showing the cycle. If you find a loop, the solution is to break the chain by replacing one of the CNAMEs with a direct A record.

To verify that your CNAMEs are configured correctly and that targets resolve, combine the CNAME Lookup with DNS Lookup for a complete picture. If you are migrating a service and need to update a CNAME target, lower the TTL first, make the change, and verify global propagation with DNS Propagation. This minimizes downtime during migrations.

CNAMEs are also used for email marketing vanity domains and tracking: links like click.newsletter.example.com are often a CNAME to the email marketing service's domain. Periodically verify that these CNAMEs are still needed and point to active services. Orphaned CNAMEs pointing to subdomains of services no longer in use can be vulnerable to subdomain takeover, a significant security risk.

Try CNAME Lookup for free
Resolve the complete CNAME chain of a hostname
Use CNAME Lookup >

Explore the Network