A CNAME (Canonical NAME) record is a DNS resource record type that points one hostname to another. When a resolver encounters a CNAME, it immediately restarts the lookup using the target name instead of the alias.
How it works
If you query www.example.com and it has a CNAME record pointing to example.com, the resolver will fetch the CNAME, then query example.com to find its A record or AAAA record and return the IP address. The alias itself never directly holds an IP address—the resolver must always follow the pointer.
Key constraints
A CNAME cannot coexist with other record types at the same name. You cannot have both a CNAME and an MX record, TXT record, or another A record on the same hostname. This is why you cannot place a CNAME at a domain's apex (the bare domain like example.com)—the apex must hold NS records and an SOA record, making a CNAME there impossible.
Example
www.example.com. CNAME example.com.
A lookup for www.example.com returns this CNAME; the resolver then queries example.com for its A/AAAA records to find the actual IP.
When it matters
CNAMEs are useful for aliasing subdomains to a single target, but avoid chaining CNAMEs (alias pointing to another alias) because it adds latency. If you need alias-like behavior at your domain apex, use a provider-specific workaround like an ALIAS or ANAME record, which is not part of the DNS standard.
WarningNever place a CNAME on the zone apex (example.com) — it conflicts with the required SOA and NS records. Use an A/AAAA record, or your provider's ALIAS/ANAME, instead.