Skip to content

Cloudflare DNS record cookbook: A, AAAA, CNAME, MX, TXT, SRV, CAA

Each DNS record type at Cloudflare — what it does, when to use it, proxied vs DNS-only behaviour, the apex CNAME flattening pitfall, the SPF/DKIM/DMARC trio for mail, and CAA to lock down certificate issuance.

The Cloudflare DNS editor has the same handful of record types every DNS interface has — A, AAAA, CNAME, MX, TXT, SRV, CAA — but a couple of Cloudflare-specific behaviours change how you reach for them. The orange cloud is the obvious one; less obvious is what Cloudflare does to a CNAME at the apex, what its proxy quietly refuses to handle, and how the certificate-issuance machinery interacts with CAA. This is the reference we hand to engineers onboarding a zone — record by record, with the proxy-mode rules and the mail-deliverability stack called out where they matter.

How to verify

Inspect every record type in a zone in one pass with the API, then spot-check resolution against a public resolver:

# List all records for the zone
curl -sS "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records?per_page=200" \
  -H "Authorization: Bearer $CF_TOKEN" \
  | jq '.result[] | {type, name, content, proxied, ttl}'

# Resolve specific types from a public resolver
dig @1.1.1.1 +short A example.com
dig @1.1.1.1 +short MX example.com
dig @1.1.1.1 +short TXT example.com
dig @1.1.1.1 +short CAA example.com
dig @1.1.1.1 +short SRV _sip._tcp.example.com

For mail records, an end-to-end check that resolves the SPF and DKIM keys plus reports DMARC alignment:

dig +short TXT example.com | grep -i spf
dig +short TXT selector1._domainkey.example.com
dig +short TXT _dmarc.example.com

What’s happening

A DNS record at Cloudflare has, at minimum, a type, a name (the hostname), and content (what it points at). For records that map a hostname to an IP-or-hostname target — A, AAAA, CNAME — there is a second axis: the proxy mode (orange or grey cloud). For the rest — MX, TXT, SRV, CAA — there is no proxy mode because nothing about those record types involves Cloudflare’s HTTP edge. The cloud icon is greyed out in the UI for them.

The orange cloud changes what gets returned at resolution time. A proxied A record does not return your origin IP; it returns a Cloudflare anycast IP, and Cloudflare proxies the HTTP/HTTPS request through its network. The origin IP is held in Cloudflare’s edge as the routing target. Anything other than HTTP/HTTPS — SSH, raw TCP, SMTP on port 25 — cannot traverse the proxy (Spectrum and Magic Transit are the paid exceptions for non-HTTP). A proxied record for SSH or SMTP black-holes the protocol.

TypeWhat it doesProxiable?Typical nameAName → IPv4Yes (HTTP/S)@, wwwAAAAName → IPv6Yes (HTTP/S)@, wwwCNAMEName → Name (alias)Yes (HTTP/S)www, appMXMail server target + priorityNo@TXTArbitrary text (SPF, DKIM, DMARC, verify)No@, _dmarcSRVService location (proto, port, target)No_sip._tcpCAAAllow-list of cert issuers for the zoneNo@
Record types and proxy applicability. Anything that is not HTTP-bound is always grey-cloud.

The procedure

The cookbook, one record type at a time:

  1. A and AAAA — host to IP. The default for any origin behind a stable IP. A example.com 203.0.113.10. Proxy mode on if you want WAF/cache, off if you only want Cloudflare’s DNS. AAAA carries the same semantics for IPv6; Cloudflare automatically proxies both when the orange cloud is on. Set TTL to “Auto” — Cloudflare overrides it to 300 seconds for proxied records anyway.

  2. CNAME — alias to a hostname. Use it when you want the target to follow somewhere else’s IPs (a SaaS endpoint, a load balancer, a CDN). CNAME www example.com aliases www back to apex. Cloudflare resolves the CNAME chain server-side, then returns the final IP — so a proxied CNAME at the edge looks like an A record to clients. Pure DNS standards forbid a CNAME at the zone apex (@), but Cloudflare does CNAME flattening: it lets you put a CNAME at apex, resolves the chain on its side, and serves the result as if it were an A. Indispensable when your apex needs to point at something like dlb-1234.elb.amazonaws.com.

  3. MX — mail server target with priority. MX example.com 10 mx1.improvmx.com. Lower priority numbers are preferred. Never proxied. The host listed in an MX must itself resolve to an IP that accepts SMTP on port 25 — if you proxied the MX hostname, the resulting Cloudflare IP would reject the connection.

  4. TXT — the catch-all for mail and verification. Three records form the mail-deliverability trio:

    • SPF at the apex, one TXT record only: v=spf1 include:_spf.google.com include:mailgun.org ~all. Multiple SPF records for the same name cause permerror; consolidate into one.
    • DKIM at a selector-named subdomain: selector1._domainkey.example.com TXT "v=DKIM1; k=rsa; p=MIGfMA0GC..." — the selector name comes from your mail provider.
    • DMARC at _dmarc.example.com: v=DMARC1; p=quarantine; rua=mailto:dmarc@example.com; pct=100. Start with p=none for a week to gather reports, then escalate to quarantine, then reject.

    TXT is also where domain-ownership verification strings land (Google Site Verification, Microsoft 365, Atlassian, etc.). Multiple TXT records on the same name are allowed and concatenated by resolvers.

  5. SRV — service discovery for non-HTTP protocols. Used by Microsoft Teams direct routing, SIP trunks, Minecraft servers, federated XMPP. Format is _service._proto.name priority weight port target. Example for Teams: _sip._tls.example.com 100 1 5061 sip.pstnhub.microsoft.com. The Cloudflare UI splits the components into separate fields. Never proxied.

  6. CAA — certificate authority authorization. Locks down which CAs can issue certificates for the zone. The record looks like CAA 0 issue "letsencrypt.org" or CAA 0 issuewild "letsencrypt.org". Without CAA, any CA can issue; with CAA, only the listed CAs may. If you proxy through Cloudflare, the edge cert is issued by Cloudflare’s CA — your CAA must include CAA 0 issue "pki.goog" and CAA 0 issue "digicert.com" and CAA 0 issue "letsencrypt.org" (the CAs Cloudflare uses) or edge certificate renewal fails silently.

    example.com.  CAA 0 issue "letsencrypt.org"
    example.com.  CAA 0 issue "pki.goog"
    example.com.  CAA 0 issue "digicert.com"
    example.com.  CAA 0 iodef "mailto:security@example.com"

For the apex-CNAME case in particular and when to keep records grey-cloud, see setting up a zone and delegating NS. For zones where DNSSEC is on, edits to records still propagate in seconds but signing is on the answer set — enabling DNSSEC safely covers the operational implications.

Common pitfalls

  • Two SPF records for the same name. Anything checking SPF returns permerror and the receiving mail server treats mail as unauthenticated. Concatenate the include: statements into a single record.
  • Proxying the MX target hostname. The MX itself cannot be proxied, but the A record the MX points at (e.g. mx1.example.com) often is — and that returns a Cloudflare IP that drops SMTP. Always grey-cloud the host an MX points at.
  • CAA on the wrong name. CAA at www does not authorize issuance for the apex; the lookup walks up the tree, so put CAA at apex and let it cover subdomains.
  • Forgetting CAA for the proxied edge. Cloudflare’s universal SSL uses multiple CAs (Let’s Encrypt, Google Trust Services, DigiCert). A CAA listing only one of them breaks automated renewal.
  • A CNAME alongside other records on the same name. Standards forbid CNAME coexisting with A/AAAA/MX/TXT. Cloudflare’s flattening hides this at apex but not elsewhere — at any non-apex name, choose CNAME or the others, not both.

In the engagements we run, the record-by-record audit is the first thing we do when a customer reports an “intermittent mail” or “cert won’t renew” problem — almost always one of the rules above was missed at import. The KB at stackharbor.com/en/knowledge-base/ collects the rest of the Cloudflare playbook we keep alongside it.