CNAME vs A record: when to point at an address and when to alias a name
By TechCompare · Updated · How we check
Pick A or AAAA records for addresses you control and a CNAME for names a provider controls. A CNAME can't share its name with any other record, so it can't sit on the root domain.
An A record maps a name straight to an IPv4 address, and an AAAA record does the same for IPv6. A CNAME works differently: it says this name is an alias, so go and look up that other name instead. Use an A record when you control the address. Use a CNAME when a service like a CDN or a hosted shop owns the address and may change it.
How this is calculated
A CNAME takes over its whole name. RFC 1034 says a name with a CNAME can't have any other records, which is why you can't put one on example.com itself: the root of a zone always needs its NS and SOA records. You also can't add a TXT or MX record next to a CNAME on the same name. That catches people out when a service asks for a verification record on www.
Many DNS hosts work around the root problem with a flattened CNAME, also sold as an ALIAS or ANAME record. The host looks up the target itself and answers with plain A and AAAA records, so resolvers never see an alias.
The cost of a CNAME is small. A resolver follows the alias and usually returns the whole chain in one answer. Long chains add a little time on a cold cache and more places for something to break, so keep them short.
The DNS Lookup shows the alias path above each record type, like www.example.com pointing to example.net, so you can see where a CNAME leads and which addresses each resolver ends up at.
Verdict
Use A and AAAA records for servers with fixed addresses you manage. Use a CNAME for www and other subdomains that point at a hosted service, so the provider can change addresses without asking you. For the root domain, use your DNS host's ALIAS or flattening option, or the A records the provider publishes.
More DNS scenarios
Related guides
Frequently asked questions
Can I put a CNAME on my root domain?
Is a CNAME slower than an A record?
Can a CNAME point to an IP address?
Related tools
Subnet Calculator
Calculate network address, broadcast address, and usable IP ranges for IPv4/IPv6.
Use toolText Encoding Converter
Convert text to Base64, binary, hex, URL encoding and HTML entities, and back again.
Use toolJWT Decoder & Validator
Decode JWT headers and claims, check exp, nbf and iat, and verify signatures locally with your own key.
Use tool