Catalog My learning Blog
Computer Networking for Developers: TCP, DNS, HTTP, TLS · Phase 2 · Lesson 12 · 3 min read

DNS Record Types, Zones and Propagation

On this page
  1. DNS record types: A, AAAA, CNAME, MX, TXT and more
  2. DNS rules that catch people out
  3. The SOA record
  4. DNS propagation is really cache expiry
  5. Check yourself

DNS record types: A, AAAA, CNAME, MX, TXT and more

Setting up a domain means editing a zone: the set of records an authoritative nameserver serves for that domain. A handful of record types cover almost everything.

TypeMapsExample
AName to IPv4 addressexample.com. A 104.20.23.154
AAAAName to IPv6 addressexample.com. AAAA 2606:4700:10::6814:179a
CNAMEName to another name (an alias)www.github.com. CNAME github.com.
MXDomain to its mail servers, with priorityexample.com. MX 10 mail.example.com.
TXTName to free textSPF, DKIM, DMARC, domain ownership checks
NSZone to its authoritative nameserversexample.com. NS hera.ns.cloudflare.com.
SOAZone metadata: primary server, serial, timersOne per zone
CAAWhich certificate authorities may issue for the domainexample.com. CAA 0 issue "letsencrypt.org"
SRVService to host and portUsed by SIP, some service discovery
A zone file with SOA, NS, A, CNAME, MX and TXT records, and what each one is for.
A zone file with SOA, NS, A, CNAME, MX and TXT records, and what each one is for.

DNS rules that catch people out

  • No CNAME at the zone apex. example.com itself has NS and SOA records, and a CNAME can't coexist with other records. DNS providers offer workarounds (ALIAS, ANAME or "CNAME flattening") that resolve the target and serve it as an A record.
  • MX and NS must point to names, not IPs, and those names need their own A or AAAA records.
  • TXT records do a lot of security work. Real examples:
Shell
dig +short TXT example.com
dig +noall +answer _dmarc.google.com TXT
Code
"v=spf1 -all"
_dmarc.google.com.  181  IN  TXT  "v=DMARC1; p=reject; rua=mailto:mailauth-reports@google.com"

v=spf1 -all says no server may send mail for example.com, a good setting for any domain that doesn't send email. Google's DMARC policy tells receivers to reject mail that fails authentication.

The SOA record

Code
example.com.  1800  IN  SOA  elliott.ns.cloudflare.com. dns.cloudflare.com. 2416374680 10000 2400 604800 1800

The fields: primary nameserver, the administrator's contact (as a name), the serial number (which increases with every change), refresh, retry and expire timers for secondary servers, and the last number, 1800 seconds here, which sets how long resolvers cache negative answers.

DNS propagation is really cache expiry

DNS changes don't spread outwards. The authoritative servers update almost immediately; what takes time is caches around the world holding the old answer until its TTL runs out. To check a change:

Shell
dig @hera.ns.cloudflare.com +short example.com A    # the source of truth
for r in 8.8.8.8 1.1.1.1 9.9.9.9; do echo "$r: $(dig @$r +short example.com A | tr '\n' ' ')"; done
YAML
8.8.8.8: 104.20.23.154 172.66.147.243
1.1.1.1: 104.20.23.154 172.66.147.243
9.9.9.9: 104.20.23.154 172.66.147.243

If the authoritative server shows the new value and public resolvers don't, wait out the TTL. If the authoritative server shows the old value, the change wasn't published, or you edited the zone at a provider the domain's NS records don't point to. Browsers and operating systems have their own caches too.

Changing nameservers is slower: NS records at the TLD often have TTLs of a day or two.

Check yourself

The apex must hold NS and SOA records, and a CNAME can't coexist with any other record for the same name; use your provider's ALIAS or flattening feature instead.

Query the authoritative nameserver directly with dig @ns1.yourdns.com name. If it already returns the new value, the change is published and 8.8.8.8 is serving its cached copy until the old TTL runs out. If not, the change didn't save or you edited the wrong zone.

No server is authorized to send email for that domain, so receivers should reject mail claiming to come from it. It's a good record for domains that never send email, protecting them from being spoofed.

An A record maps a name to an IPv4 address. An MX record names the mail servers for a domain, with priorities, and must point to a hostname, not an IP.

It names the zone's primary nameserver and administrator and holds the serial number and timers secondary servers use to know when to refresh, plus the TTL for negative answers.