DNS & Records

CNAME — Canonical Name

DNS record that acts as an alias: points one hostname to another.


What is a CNAME

A CNAME (Canonical Name) is a DNS record that acts as an alias: it points one hostname to another. When a resolver finds a CNAME, it follows the pointer until it reaches an A record.

Example

www.example.com.    IN  CNAME  example.com.
shop.example.com.   IN  CNAME  shopify-host.myshopify.com.
mail.example.com.   IN  CNAME  ghs.googlehosted.com.

With the first entry, anyone requesting www.example.com will look up example.com and receive its apex A record. With the second, the lookup chain goes to Shopify's nameservers, which return the IP of their own infrastructure.

CNAME usage rules

  • Cannot coexist with another record type for the same hostname (e.g. you cannot have both a CNAME and an MX for example.com).
  • Not allowed at the apex of a domain. You need an A record or ALIAS/CNAME-flattening from your provider.
  • CNAME chains are allowed but increase latency and resolver load. Do not use more than 2–3 hops.

When to use it

  • When hosting a service on a third party (Shopify, Squarespace, GitHub Pages) that may change its IP — you set a CNAME and they manage the IP.
  • To consolidate multiple subdomains under a single canonical hostname.
  • For CDN integrations that need flexibility in IP routing.

Related tools

Related terms

Related guides