← DNS RecordsRecord Type / Alias

CNAME Record

Creates an alias from one hostname to another canonical name. The resolver follows the chain until it reaches an A or AAAA record.

Overview

Canonical Name Alias

A CNAME (Canonical Name) record creates an alias — it says "this hostname is actually another hostname." Resolvers follow CNAME chains until they find an A or AAAA record. This means a single IP change at the canonical name propagates immediately to all aliases pointing to it.

CNAMEs are frequently used to point subdomains at CDN, SaaS, or cloud provider hostnames: app.example.com CNAME myapp.vercel.app.. When the provider changes their IP infrastructure, your DNS automatically reflects it without any changes on your end.

  • Cannot be used at the zone apex — the root of your domain (@) must have A/AAAA, NS, and SOA records; a CNAME would conflict
  • A CNAME record cannot coexist with any other record type on the same name (RFC 1034)
  • CNAME chains work but add latency — each hop requires an additional DNS lookup
  • MX and NS records cannot point to a CNAME — they must point directly to A/AAAA records
  • Many DNS providers offer CNAME flattening (ALIAS/ANAME) to enable apex CNAME-like behavior
; Syntax ; Name [TTL] IN CNAME target-hostname. ; Common use: www alias www 3600 IN CNAME thedns.guru. ; Pointing at CDN/SaaS app 3600 IN CNAME myapp.vercel.app. cdn 3600 IN CNAME d111111abcdef8.cloudfront.net. mail 3600 IN CNAME ghs.googlehosted.com. ; CNAME chain (each hop = extra lookup) a IN CNAME b.example.com. b IN CNAME c.example.com. c IN A 203.0.113.1
CNAME at Apexexample.com CNAME other.com.This is invalid. The apex must carry NS and SOA records, which cannot coexist with CNAME. Use CNAME flattening (Cloudflare, Route 53 ALIAS, Netlify) to achieve equivalent behavior at the apex.
CNAME Flattening

Using CNAMEs at the Apex

CNAME flattening (also called ALIAS or ANAME records depending on the provider) solves the apex restriction. The DNS provider resolves the CNAME target at query time and returns the resulting A/AAAA records as if they were directly on your apex. The client never sees a CNAME in the response.

This is essential for services like Netlify, Vercel, Heroku, and Cloudflare Pages that require you to point your naked domain at their infrastructure. Without flattening, you would need to hard-code an IP address (which may change) in your A record.

; Cloudflare — use CNAME at apex, ; Cloudflare automatically flattens it ; In Cloudflare DNS dashboard: ; Type: CNAME Name: @ ; Target: mysite.netlify.app ; What the resolver actually receives: ; (flattened — no CNAME visible) example.com. A 75.2.60.5 example.com. A 99.83.231.61 ; Route 53 ALIAS record (equivalent): ; example.com ALIAS mysite.netlify.app. ; → AWS resolves to A records inline
Diagnostics

Querying CNAME Records

Look up a CNAME

# Query CNAME record dig www.thedns.guru CNAME +short # Follow the full chain dig www.thedns.guru A +short # (returns final A record IPs) # See each hop in the chain dig www.thedns.guru CNAME

Verify no CNAME at apex

# The apex should NOT have CNAME dig thedns.guru CNAME +short # Should return empty # Apex should have A/AAAA dig thedns.guru A +short # NS and SOA always at apex dig thedns.guru NS +short dig thedns.guru SOA +short