Cloudflare Docs
DNS
DNS
Edit this page
Report an issue with this page
Log into the Cloudflare dashboard
Set theme to dark (⇧+D)

How CNAME flattening works

With CNAME flattening, Cloudflare returns an IP address instead of the target hostname that a CNAME record points to. This process supports a few features and delivers better performance and flexibility, as mentioned in the CNAME flattening concept page.

Consider the diagram below to have an overview of the steps that may be involved in CNAME flattening.

​​ Example use case

  • domain.test is a zone on Cloudflare and has the following CNAME record:
TypeNameContentTTL
CNAMEdomain.testexternal-origin.test3600
  • external-origin.test is a zone on a different DNS provider and has the following A record:
TypeNameContentTTL
Aexternal-origin.test192.0.2.17200

In this case, the process to respond to queries for domain.test directly with the IP address can be represented by the following diagram:

CNAME flattening diagramDiagram of CNAME flattening process when there is a request for a domain in Cloudflare and the zone has a CNAME record at apex that points to an external A record.
External DNS provider
Cloudflare DNS
query for domain.test
Proxied
DNS only
Answer:
external-origin.test 7200 IN A 192.0.2.1
Resolve external-origin.test
Answer:
domain.test 3600 CNAME external-origin.test

This means that domain.test is a CNAME at the zone apex.
Forced CNAME flattening is enabled.
Look up record
Proxy status
Answer:
domain.test 7200 IN A 192.0.2.1
Append answer with overwritten query name
Answer:
domain.test 300 IN A {$Cloudflare IP 1}
domain.test 300 IN A {$Cloudflare IP 2}
Answer:
domain.test 3600 IN A 192.0.2.1
User
Resolver
Question:
domain.test IN A

​​ Aspects to consider

  • If the CNAME record is proxied in Cloudflare, the answer is made up of multiple Cloudflare IPs and its Time to Live (TTL) is set to 300.
  • If the CNAME record in Cloudflare is not proxied, the flattened answer consists of the IP address from the external DNS provider and its TTL corresponds to the lower value between the external record and the Cloudflare CNAME record.