Skip to content
Tutorials Center
My learning

Topics

Lesson 6 of 36 ยท DNS and Proxying

DNS Record Types in Cloudflare: A, AAAA, CNAME, MX, TXT and More

A practical guide to DNS record types you will configure in Cloudflare: A, AAAA, CNAME, MX, TXT, SRV, CAA, NS and how to validate them correctly.

Different jobs need different record types. Choosing the wrong one is the most common DNS mistake, and Cloudflare's form will happily accept some of them. This lesson reviews each type you will meet, shows the rules that trip people up, and builds a validator so you can test your understanding.

The essential types

Records that point to places

A Name to IPv4 address
AAAA Name to IPv6 address
CNAME Name to another name

A, AAAA and CNAME can be proxied.

1 / 2

A and AAAA

An A record maps a name to an IPv4 address (203.0.113.10). An AAAA record maps it to IPv6 (2001:db8::10). Publish both if your origin supports IPv6; visitors then use whichever they have. A name may have several A records, and resolvers rotate through them.

CNAME

A CNAME says "this name is an alias of that name". The visitor follows the alias and uses the target's addresses. Use it when the target's IP may change and is managed by someone else, such as shop.example.com -> shops.provider.net.

Rules:

  • A CNAME must be the only record at its name. You cannot have a CNAME and an MX or TXT at blog.example.com.
  • The traditional DNS rule forbids a CNAME at the zone apex (example.com), because the apex must hold NS and SOA records. Cloudflare allows it through CNAME flattening: it resolves the target itself and returns plain A/AAAA answers. Flattening is applied automatically at the apex.

MX

MX records list mail servers with a priority: the lowest number is tried first.

TEXT
example.com.  MX  10 mx1.mailhost.net.
example.com.  MX  20 mx2.mailhost.net.

The target must be a hostname with an A/AAAA record, never an IP address and never a CNAME. MX records can not be proxied: Cloudflare's HTTP proxy does not carry mail.

TXT

TXT records hold free text. They carry email policy (SPF, DKIM, DMARC, covered in its own lesson), domain ownership tokens ("google-site-verification=...") and ACME challenges. A long value may be split into several quoted strings of up to 255 characters; resolvers join them.

NS

NS records at the apex name the authoritative nameservers, controlled at the registrar. In Cloudflare you may add NS records for subdomain delegation (dev.example.com handled by another provider), but you cannot change the apex NS.

SRV and CAA

An SRV record tells clients the host and port of a service: _sip._tcp.example.com. SRV 10 60 5060 sip.example.com. The four numbers are priority, weight, port, then the target.

A CAA record restricts which certificate authorities may issue certificates for your domain, for example 0 issue "letsencrypt.org". Cloudflare's own certificates must remain allowed if you use them; the dashboard adds the right CAA records automatically when needed.

Others

PTR (reverse lookups, held by the IP owner), HTTPS and SVCB (hints for protocol and address, used for HTTP/3 and ECH), TLSA (DANE), SSHFP, URI and several more exist, and the dashboard offers many.

A cheat table

Type Value looks like Proxiable Typical use
A 203.0.113.10 yes Website server
AAAA 2001:db8::10 yes IPv6 website
CNAME target.example.net yes Alias to a service
MX 10 mail.example.com no Email delivery
TXT "v=spf1 ..." no Policies, verification
SRV 10 60 5060 host no Service discovery
CAA 0 issue "ca.example" no Certificate restriction

Validating records

Mistakes often come from a wrong value type. The stand-in below checks the typical rules: IP formats, CNAME exclusivity, MX priority and target form.

JS Stand-in: DNS record validator

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Add your own records and rerun. Each message corresponds to a mistake that causes real outages: a CNAME with a neighbor record behaves unpredictably, an MX pointing to a raw IP is invalid, and an out-of-range octet is rejected.

Priority, weight and multiple records

When several MX records exist, mail servers try the lowest priority number first and move up on failure. Equal priorities share load. SRV adds a weight for load sharing among equal priorities. For web traffic, several A records give simple distribution but no health checking: if one server dies, clients may still be sent to it. For real failover use a load balancer (Cloudflare Load Balancing is a paid product) or an upstream proxy with health checks.

Practical tips

  • Use dig to see what the world sees: dig A www.example.com +short, dig MX example.com +short, dig TXT example.com +short.
  • Query Cloudflare's resolver directly to bypass your local cache: dig @1.1.1.1 example.com.
  • Keep a comment on every record explaining its owner and purpose.
  • Delete records for services you retired. A dangling CNAME that points to a deleted cloud resource can be claimed by an attacker, called a subdomain takeover.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which record type should map a name to an IPv6 address?

    AAAA is the IPv6 address record.
  2. 2. Why can't you place a CNAME and a TXT record at the same name in standard DNS?

    An alias replaces all data for that name, so no other record types may coexist with it.
  3. 3. In MX records, which server is tried first?

    Lower preference value means higher priority.
  4. 4. What allows a CNAME-like alias at the zone apex in Cloudflare?

    Cloudflare resolves the target and answers with A/AAAA records.
  5. 5. What risk comes from keeping a CNAME to a deleted cloud service?

    An attacker can register the abandoned target and serve content on your subdomain.

Summary

  • A/AAAA point to IPs, CNAME aliases a name, MX routes mail, TXT carries policies and tokens, SRV and CAA serve special roles.
  • A CNAME must stand alone at its name; Cloudflare flattens CNAMEs at the apex.
  • Only A, AAAA and CNAME records can be proxied.
  • Validate values, retire unused records and inspect results with dig.

Next: Proxy status: orange and grey cloud