HTTPfy

CNAME record

A CNAME (canonical name) record says "this name is an alias; look up that other name instead". Resolvers follow it and return the target's records.

type code 5 RFC 1034RFC 2181

Live CNAME records from real domains

Checked at via public DNS
www.github.comCNAME
www.github.com. 3600 IN CNAME github.com.
  ; points to github.com
www.amazon.comCNAME
www.amazon.com. 1800 IN CNAME tp.47cf2c8c9-frontier.amazon.com.
  ; points to tp.47cf2c8c9-frontier.amazon.com
www.microsoft.comCNAME
www.microsoft.com. 2388 IN CNAME www.microsoft.com-c-3.edgekey.net.
  ; points to www.microsoft.com-c-3.edgekey.net
www.apple.comCNAME
www.apple.com. 123 IN CNAME www-apple-com.v.aaplimg.com.
  ; points to www-apple-com.v.aaplimg.com

What the CNAME record does

CNAMEs are how most CDNs and SaaS platforms are attached: www.example.com points at a name the provider controls, and the provider can change addresses without touching your zone. A resolver that meets a CNAME restarts the query at the target, possibly through several CNAMEs, and returns the whole chain.

A CNAME replaces all other data at its name. RFC 1034 section 3.6.2 and RFC 2181 section 10.1 forbid other records alongside it (DNSSEC records excepted). Because the zone apex always has SOA and NS records, a CNAME cannot be placed there. Providers offer non-standard "ALIAS", "ANAME" or "CNAME flattening" features instead, which answer with A/AAAA records.

Zone-file syntax

www.example.com.  3600  IN  CNAME  example.cdn-provider.net.

Wire format: RDATA is a single domain name, the canonical name, in DNS label format.

Fields

FieldMeaning
OwnerThe alias. It may hold no other records apart from DNSSEC ones.
TargetThe canonical name. Write it fully qualified with a trailing dot in a zone file, or it is treated as relative to the zone.

Common mistakes

  • A CNAME at the apex (example.com). It breaks MX, NS and SOA and is rejected by most DNS hosts. Use ALIAS/flattening or A records.
  • Missing trailing dot: www CNAME cdn.example.net becomes cdn.example.net.example.com..
  • Pointing MX or NS records at a name that is a CNAME. RFC 2181 section 10.3 says they must point at a name with address records.
  • Long CNAME chains through several providers. Each hop adds lookups and another dependency.

Specification

  • RFC 1034: Domain names - concepts and facilities
  • RFC 2181: Clarifications to the DNS Specification

Related record types

  • A: map a hostname to an IPv4 address
  • AAAA: map a hostname to an IPv6 address
  • HTTPS: ALPN, address hints and ECH for websites

All DNS record types