We can use a CNAME record at our root/apex domain with Cloudflare CNAME flattening, which speeds up CNAME resolution.
Let’s take a closer look at Cloudflare’s CNAME flattening.
To discover the IP address that a CNAME points to, Cloudflare uses CNAME flattening. Single or multiple lookups may be used in this procedure (if your CNAME points to another CNAME). Instead of a CNAME record, Cloudflare returns the final IP address, which accelerates DNS query resolution by up to 30%.
As per DNS specifications, a domain cannot have both a CNAME and another type of DNS record with the same name (RFCs). This can become an issue when we need a CNAME for our root domain but also need a different type of DNS record, such as an MX record for mail delivery.
In most cases, the above scenario would lead to email delivery problems. CNAME Flattening, on the other side, makes sure that the chain of CNAMEs results in an A or AAAA record, enabling mail delivery while maintaining DNS RFC compliance. CNAME actions are cached and DNS TTLs are respected. CNAME Flattening will still work if the corresponding DNS CNAME record in the Cloudflare dashboard’s DNS app is “grey cloud.”
Configure CNAME flattening
For your root domain
CNAME flattening is enabled by default for all plans when our domain uses a CNAME record for its root domain.
For all CNAME records
Premium versions have the option of flattening all CNAME records on a domain. This option is useful for DNS-only (unproxied) CNAME records because proxied records are flattened by default.
- To begin, log into Cloudflare and select the account and domain.
- After that, go to DNS.
- At last, for CNAME Flattening, select Flatten all CNAMEs.
How do I change the CNAME Flattening settings?
It is not possible to disable CNAME flattening. By default, domains are configured to only flatten CNAME records at the root domain.
On the Pro, Business, and Enterprise plans, we can flatten CNAMEs at the root domain or all CNAMEs within a domain. To flatten all CNAMEs in the domain, choose Flatten all CNAMEs from the CNAME Flattening dropdown list in the Cloudflare dashboard’s DNS app.
Are you looking for an answer to another query? Contact our technical support team.