CNAME Record: What a Canonical Name Is, Syntax, Rules, and Examples

A Canonical Name (CNAME) record is a DNS resource record that maps an alias subdomain (such as www.example.com) to another target domain name (such as example.com) instead of an IP address. Resolvers follow the target name to find its IP. The rules of a CNAME prohibit root-domain placement.

Browser Resolver Root+TLD Authoritative Website query solid = query · dashed = cached response · every hop caches until TTL
CNAME alias resolution: the recursive resolver follows the alias pointer to fetch the canonical target's IP address

What Is a Canonical Name and What Does a CNAME Record Look Like?

In DNS terminology, a Canonical Name is the true, authoritative target hostname on the right-hand side of the record (example.com), whereas the subdomain label on the left-hand side (www.example.com) is the alias (nickname) being redirected. A CNAME record (IANA Type 5) contains 4 zone fields (Host/Alias, Type, TTL, and Target/Canonical Name) that instruct recursive resolvers to substitute the target domain's DNS records whenever a client queries the alias. A common production alias is the Outlook autodiscover CNAME, which the Autodiscover checker verifies against your mail provider, while a *.example.com CNAME catch-all carries takeover exposure that the Wildcard DNS tester probes directly. The table below defines the technical specifications of a CNAME record.

; Alias (Left)             TTL   Class  Type   Canonical Name (Right)
www.example.com.           3600  IN     CNAME  example.com.
shop.example.com.          3600  IN     CNAME  shops.myshopify.com.
Zone Field Format Example Protocol Constraint
Host / Alias Subdomain String www, shop Alias label; prohibited at zone apex (@).
Record Type Type 5 CNAME Aliases all records to canonical target.
TTL Integer Seconds 3600 Cache retention duration in seconds.
Class IN (Internet) IN Standard Internet class.
Target / Points To FQDN Hostname example.com Canonical destination hostname.

Distinguishing the alias from the canonical name governs DNS setup: the Name input holds the alias subdomain (www or shop), while the Target input holds the canonical destination name (example.com or shops.myshopify.com). Verify any live target instantly using our CNAME Record Lookup.

How Does a CNAME Record Lookup Work Step by Step? (5 Steps)

Resolving a subdomain that uses a CNAME record requires 5 lookup steps where the recursive resolver follows the alias pointer to fetch the canonical target's A or AAAA IP address:

  1. Request the IPv4 or IPv6 address for www.example.com from the browser to the recursive resolver.
  2. Query the authoritative nameserver for example.com and receive the CNAME record pointing www.example.com to example.com.
  3. Restart the query at the recursive resolver for the canonical target (example.com) to retrieve its A Record or AAAA Record.
  4. Return the CNAME chain and final IP address (93.184.216.34) in the answer section, caching each entry by its DNS TTL Explained value.
  5. Open the TCP connection and TLS handshake to 93.184.216.34 while sending Host: www.example.com and keeping www.example.com in the browser bar.

Resolvers execute an additional external query when the target resides on another domain (such as shop.example.com pointing to shops.myshopify.com), resolving external nameservers before delivering the web server IP via A Record Lookup.

What Are the 4 Strict Rules and Restrictions of a CNAME Record?

The DNS protocol enforces 4 strict architectural rules covering coexisting records, the root domain (@), MX/NS targets, and multi-hop CNAME chains:

  1. A CNAME Record Never Coexists With Other Records on the Same Hostname: Aliasing a hostname redirects all queries to the target, prohibiting TXT, MX, or A records on that label (except DNSSEC RRSIG and NSEC records).
  2. A Standard CNAME Record Cannot Sit at the Zone Apex (@ Root Domain): Root domains (example.com) mandate SOA and NS records. Placing a CNAME at @ breaks delegation, requiring ALIAS and ANAME Records or CNAME Flattening.
  3. MX and NS Records Never Point to a CNAME Target: Hostnames in an MX Record and nameservers in an NS Record point strictly to address records. Mail servers reject MX records pointing to CNAME aliases.
  4. Avoid Chaining One CNAME to Another CNAME (A -> B -> C): Pointing blog.example.com to www.example.com while www.example.com points to app.cloud.net creates multi-hop lookups that increase latency. Point every alias directly to the final canonical hostname.

Organizations needing to alias an entire subtree of subdomains simultaneously deploy a DNAME (Delegation Name, Type 39) record, redirecting entire hierarchical namespace branches rather than individual labels.

5 Real-World Examples of How Websites and Email Use CNAME Records

Production domains rely on CNAME records across 5 common use cases: www subdomain routing, SaaS custom domains, CDN edge endpoints, delegated DKIM keys, and automated SSL validation:

  1. Pointing www to Your Root Domain (www.example.com -> example.com): Routes web traffic destined for www to root domain address records, updating www automatically when apex IPs change.
  2. Connecting Subdomains to SaaS Platforms (Shopify, HubSpot, Vercel): Maps subdomains like shop.example.com to shops.myshopify.com, letting cloud providers rotate load-balancer IPs dynamically without customer DNS edits.
  3. Delegating Outbound Email Keys via DKIM Explained: Email platforms like Microsoft 365 and SendGrid publish CNAMEs in customer zones, rotating 2048-bit signing keys on provider infrastructure.
  4. Routing Static Assets Through a CDN (cdn.example.com -> d111111abcdef8.cloudfront.net): Directs asset delivery to global Anycast edge networks like Amazon CloudFront, managing edge caching transparently.
  5. Automating ACME DNS-01 SSL Renewals (_acme-challenge): Directs validation queries to dedicated validation endpoints, allowing certificate authorities to verify domain control and issue wildcard certificates automatically.
; 1. www alias
www.example.com.              3600  IN  CNAME  example.com.

; 2. SaaS custom domain
shop.example.com.             3600  IN  CNAME  shops.myshopify.com.

; 3. Delegated DKIM
s1._domainkey.example.com.    3600  IN  CNAME  s1.domainkey.u1234567.wl001.sendgrid.net.

; 4. CDN endpoint
cdn.example.com.              3600  IN  CNAME  d111111abcdef8.cloudfront.net.

; 5. ACME challenge
_acme-challenge.example.com.  300   IN  CNAME  _acme-challenge.example.com.dcv.cloudflare.com.

Cloudflare users configure proxy settings attentively: enable Orange Cloud on web CNAMEs (www or shop) for CDN caching, but keep DKIM (_domainkey) and SSL validation (_acme-challenge) CNAMEs strictly DNS Only (Grey Cloud) so external verifiers inspect the raw target.

CNAME Record vs A Record vs ALIAS vs HTTP 301 Redirect (Comparison Table)

Beginners frequently confuse a DNS CNAME record with an A record, an ALIAS record, or an HTTP 301/302 URL Redirect, even though DNS records only resolve IP addresses and never rewrite URLs in browser address bars. The table below compares all 4 mechanisms side by side.

Feature / Behavior CNAME Record A / AAAA Record ALIAS / ANAME Record HTTP 301 / 302 URL Redirect
Layer of Operation DNS Layer (Type 5) DNS Layer (Type 1 / 28) DNS Layer (Virtual Type 1/28) HTTP Server (Port 80/443)
Target Value Format Another domain (example.com) IPv4/IPv6 (93.184.216.34) Another domain (app.paas.com) Full URL (https://example.com/new)
Changes Browser URL Bar? No (Keeps typed subdomain) No (Keeps typed hostname) No (Keeps typed root domain) Yes (Redirects address bar)
Redirects URL Paths (/path)? No (DNS is path-unaware) No (DNS is path-unaware) No (DNS is path-unaware) Yes (/old-path -> /new-path)
Permitted at Zone Apex (@)? No (Conflicts with SOA/NS) Yes Yes (Synthesizes A/AAAA) Yes (Requires underlying DNS)

Pointing olddomain.com to newdomain.com via CNAME does not forward visitors to https://newdomain.com/ in the address bar. DNS only resolves domain names to IP addresses; the web server serves an HTTP 301 Moved Permanently header and matching TLS certificate. Review our guide to DNS Record Types for full specifications.

Security Warning: How Dangling CNAME Records Cause Subdomain Takeovers

A dangling CNAME record occurs when a subdomain (promo.example.com) points via CNAME to an external cloud service (such as GitHub Pages, AWS S3, or Azure) after deleting the cloud resource, exposing the subdomain to a Subdomain Takeover attack. Threat actors exploit orphaned pointers to impersonate legitimate brands.

Subdomain takeover exploitation follows an automated 3-step sequence:

  1. Discover the abandoned CNAME record (promo.example.com -> oldcampaign.github.io) using public DNS scanners after canceling cloud hosting without cleaning up DNS zones.
  2. Register that exact unclaimed project name (oldcampaign) on the cloud platform, hijacking promo.example.com to host phishing pages, steal cookies, and bypass brand filters.
  3. Prevent subdomain takeovers by deleting every CNAME pointer before deprovisioning cloud services, while auditing zones regularly for dangling records.

A dangling CNAME returning NXDOMAIN indicates an active takeover risk. Security teams remove orphaned CNAME pointers immediately to protect corporate namespace integrity.

How to Check and Verify a CNAME Record (dig, nslookup, and Browser DoH)

Inspect the canonical target and TTL of any CNAME record using our browser lookup tool or running a dig or nslookup command in your terminal:

# Query only the CNAME target on Linux / macOS:
dig www.example.com CNAME +short

# Query the full CNAME -> A resolution chain:
dig www.example.com A +noall +answer

# Query CNAME on Windows Command Prompt:
nslookup -type=cname www.example.com 1.1.1.1

Output from these diagnostics reveals the complete delegation path from alias to IP address. Verify worldwide resolution synchronization across global checkpoints with our DNS Propagation Checker whenever updating records. Understanding CNAME record architecture, canonical destination mappings, zone apex coexistence restrictions, and differences between CNAME records, address records, and HTTP redirects ensures resilient infrastructure across modern networks.

Frequently asked questions

Which side of a CNAME record is the "Canonical Name"?+

The right-hand target value (the destination domain the record points to, such as example.com) is the Canonical Name ("true name"). The left-hand Host/Name field (such as www.example.com) is the alias (nickname).

Does a CNAME record redirect a URL or change the address bar in the browser?+

No, a CNAME record only resolves the domain name to the target's IP address at the DNS layer. The visitor's browser address bar continues showing the alias URL they typed. Changing the URL in the browser bar requires an HTTP 301 or 302 redirect on the web server.

Does using a CNAME record instead of an A record slow down my website?+

No, in practice, if your CNAME points to a target inside the same DNS zone (like www.example.com -> example.com), there is zero extra latency because your authoritative server returns both records in a single packet. Pointing to an external domain adds only 5 to 25 ms on the first uncached lookup.

Why won't my DNS provider let me add a TXT record on a subdomain that already has a CNAME?+

In real-world setups, this happens because DNS rules strictly prohibit a CNAME from sharing a hostname with any other record type. Ask the vendor for a root-domain TXT token or replace the CNAME with an A/ALIAS record whenever a third-party service requests a verification TXT string on an existing CNAME subdomain.

Last verified: 2026-11-28