CNAME Records

A CNAME (Canonical Name) record creates an alias from one domain name to another. The DNS lookup will continue for the destination domain.

A CNAME against a direct A recordwww.example.comCNAMEexample.comA93.184.216.34example.comA93.184.216.34
A CNAME adds one more lookup before the address is found.

How CNAME Records Work

When a client queries a CNAME record, the DNS server responds with the canonical name and then the client must perform another lookup for that canonical name.

CNAME Record Format

blog.example.com.    CNAME    hashnode.network.
shop.example.com.    CNAME    shops.shopify.com.

When to Use CNAME

  • Pointing a subdomain to a third-party service (blog, shop, etc.)
  • Creating aliases for CDN domains
  • Mapping multiple hostnames to the same server

CNAME vs A Record

CNAMEA Record
Points to a domain namePoints to an IP address
Requires additional lookupDirect resolution
Can only be used for subdomainsCan be used for any name
Cannot coexist with other records*Can have other records

* A CNAME cannot coexist with other records at the same name (except DNSSEC)

Best Practices

  • Don't use CNAME at the root domain (example.com) for your main website
  • Ensure the target domain always resolves
  • Test with our CNAME Lookup tool
Try it on your domain

See the theory in practice — run a CNAME Lookup for your own domain.