Why can you not put a CNAME record on the root domain, such as example.com?
A CNAME means this name is an alias for another name, so no other record may exist at it. The root of a zone must also hold NS and SOA records, so a CNAME there would conflict. Providers offer ALIAS, ANAME or CNAME flattening as a workaround.
Explain it simply
A CNAME is a forwarding note: "for anything about me, ask that other person". If you also try to keep your own address book entries, they conflict with the note. The root of a domain must keep its own entries, so it cannot be only a forwarding note.
Example
Allowed:
www.example.com. CNAME myapp.hosting.net.
Not allowed (breaks the zone):
example.com. CNAME myapp.hosting.net.
example.com. NS ns1.example.net. <- must coexist at the apex
example.com. SOA ...
example.com. MX 10 mail.example.com. <- email would break tooThe rule says that if a name has a CNAME, it cannot have any other record type. The apex always has SOA and NS, and usually MX and TXT.
Workarounds: use A and AAAA records with the host's IP addresses, or use your DNS provider's ALIAS/ANAME/flattening feature. The provider resolves the target itself and answers with plain A records. Another route is to redirect the bare domain to www with an HTTP redirect.
What to say in the interview
"A CNAME cannot coexist with other records at the same name, and the zone apex must carry SOA and NS. So I use A/AAAA records, or the provider's ALIAS or CNAME flattening, or redirect to www."
Common mistakes
- Using a CNAME at the apex because it worked in a tutorial for a subdomain.