A developer asks why their domain stops receiving mail after they “pointed example.com at the CDN”. They added a CNAME at the apex (example.com IN CNAME cdn.provider.net) because the CDN documentation said so. The mail stopped flowing because of how CNAMEs interact with other records — not because of the CDN. The rule is in the original DNS spec and predates everyone reading this.
What’s happening
RFC 1034 says a CNAME and any other record cannot coexist at the same name. A CNAME means “ask the target for everything”; if a name has a CNAME, no other record at that name is consulted, ever. At the apex of a zone, that’s catastrophic because the apex must have SOA and NS records by definition. Putting a CNAME at the apex either:
- Gets rejected by
namedat zone load (named-checkzonewill refuse), or - Loads but produces undefined behaviour where MX, TXT, and other apex records are ignored when the CNAME is honoured.
cPanel’s Zone Editor will refuse to add a CNAME at the apex with a clear error. WHM’s raw editor will accept it but named will reject the zone on the next reload. Some hosted DNS providers silently allow it with vendor-specific extensions (Route 53’s ALIAS, Cloudflare’s CNAME flattening), but those are not standard CNAMEs — they resolve at the server side and return A/AAAA records, not CNAMEs.
How to verify
Confirm what record set the apex has:
dig +noall +answer example.com ANY
dig +short A example.com
dig +short CNAME example.com
dig +short MX example.com
A correct apex has A and/or AAAA, plus MX, NS, SOA — no CNAME. If you see a CNAME at the apex from any resolver, you’re looking at a CNAME-flattening provider (Cloudflare, Route 53 alias) returning the resolved record as if it were a direct A.
Check named logs for zone load errors:
grep -i 'CNAME and other' /var/log/messages
tail -100 /var/named/data/named.run
The fix
Pick one of these three workarounds depending on your DNS provider and the target’s behaviour:
- Resolve the target manually to A/AAAA and publish those. Works when the CDN endpoint has a stable IP. Fails when the CDN rotates IPs every few hours, because your A record will lag.
- Move the apex to a CDN that supports flattening (Cloudflare DNS, Route 53). The flattening provider keeps the CNAME-equivalent in their config but returns A records to resolvers. Mail and other apex records remain because the flattening happens server-side, not in the published zone.
- Use
www.example.comas the canonical name and 301-redirectexample.comtowww.example.com. The redirect is served by a small origin that has a stable A record. The CNAME-pointing-to-CDN lives onwww, which is a normal subdomain.
For a cPanel-hosted zone where the customer demands the apex points at a CDN:
dig +short cdn.provider.net A
Take the IPs returned, publish them as A records on the apex, and set up an automated job to re-resolve and update the records (the cPanel host can run a cron with dig plus whmapi1 editzonerecord). Build in a TTL of 300 so the IP rotation has a useful window.
If the CDN’s IPs rotate aggressively (Cloudflare’s edge changes daily, Akamai rotates often), option 3 is the only one that’s stable long term. The redirect lives on a 1-vCPU origin with no scaling concern — it does nothing but issue a 301.
Stack Harbor handles apex CNAME workarounds during CDN onboarding as part of deployment management.