DNS Record Types Explained: A, AAAA, CNAME, MX, TXT, NS, SOA and When Each Matters
DNS is the phone book of the internet, but the "phone book" metaphor hides the part that actually bites developers: there is no single record per domain, there are a dozen record types, each with its own rules. Misconfigure a CNAME at your apex and email breaks. Set the wrong TTL before a migration and users see the old server for hours. This is the working guide to the record types you will actually touch, what breaks when you get them wrong, and how to check any of them in seconds.
A and AAAA — the address records
The A record maps a name to an IPv4 address (93.184.216.34); the AAAA record does the same for IPv6. These are the only records that point directly at a server. Everything else either aliases to a name that eventually resolves to an A/AAAA record, or carries metadata.
Practical notes: you can have multiple A records for one name (round-robin load distribution — clients pick one, roughly at random). And when you move hosts, the A record is what you change; everything about "DNS propagation" is really about how long caches keep the old A record answer, which brings us to TTL below.
CNAME — the alias, with one hard rule
A CNAME says "this name is just another name for that name" — www.example.com → example.com, or app.example.com → my-app.vercel.app. The resolver follows the chain until it hits an A or AAAA record.
The hard rule: a CNAME cannot coexist with any other record type at the same name. This is why you cannot put a CNAME at your apex (bare domain): the apex must have SOA and NS records, so a CNAME there is illegal. Providers work around this with proprietary flattening (Cloudflare calls it CNAME flattening, Route53 calls them alias records) that resolves the target and serves the result as synthetic A records. If your apex "CNAME" works, that is what is happening underneath.
MX — where your email goes
MX records name the mail servers that accept email for your domain, each with a priority number — lower wins, and the others are fallbacks. Two things trip people up: MX targets must be hostnames, not IP addresses, and those hostnames must themselves have A/AAAA records (a MX pointing at a CNAME is technically allowed but widely discouraged because it doubles lookups). If email suddenly stops after a DNS change, check MX first — it often gets clobbered when someone recreates the zone file.
TXT — the junk drawer that runs security
TXT records hold arbitrary strings, and an entire ecosystem grew up inside them:
- SPF — which servers may send email as your domain (
v=spf1 include:_spf.google.com ~all) - DKIM — the public key recipients use to verify your mail signatures
- DMARC — what recipients should do when SPF or DKIM fails
- Verification — proving domain ownership to Google Search Console, Microsoft, Stripe, and everyone else ("add this TXT record")
One domain can have many TXT records, and order does not matter. The classic mistake is creating a second SPF record instead of merging includes into the existing one — two SPF records make both invalid, and your email deliverability silently degrades.
NS and SOA — who is in charge
NS records delegate a zone to nameservers; they are set at your registrar and inside the zone itself. Changing hosts or moving to Cloudflare means changing NS at the registrar, and the old and new nameservers must serve the same records during the transition or things flap. SOA (Start of Authority) is the zone's metadata record: primary nameserver, admin contact, and the serial number secondary servers use to know when to re-sync. You rarely edit SOA by hand, but its refresh/retry/expire timers explain why some secondaries lag hours behind.
TTL — the number that decides how fast changes apply
Every record carries a TTL in seconds: how long resolvers may cache the answer. A TTL of 3600 means your change can take an hour to be visible everywhere; 86400 means a day. Before any migration, lower the TTL to 300 a day ahead, make the change, verify, then raise it back. Forgetting this is the difference between a 5-minute cutover and a day of "it works for me but not for the client."
Quick reference
| Type | Holds | Watch out for |
|---|---|---|
A | IPv4 address | Multiple records = round-robin |
AAAA | IPv6 address | Missing AAAA on an IPv6-only host = unreachable |
CNAME | Alias to another name | Illegal at the apex; cannot coexist with other records |
MX | Mail servers + priority | Target must be a hostname with an A record |
TXT | Arbitrary strings | Two SPF records invalidate both |
NS | Authoritative nameservers | Keep old and new serving during moves |
SOA | Zone metadata + serial | Timers explain secondary lag |
SRV | Service host + port | Used by SIP, XMPP, Minecraft, not web |
CAA | Which CAs may issue certs | A wrong CAA blocks certificate issuance |
PTR | Reverse: IP → name | Set at the IP owner, not your DNS provider |
Debugging in the real world
When something DNS-shaped breaks, work the chain: query the record, then query it against a specific resolver (dig example.com A @1.1.1.1), then against the authoritative nameserver (dig example.com A @ns1.yourhost.com). If the authoritative answer is right but the resolver answer is stale, you are waiting on TTL. If the authoritative answer is wrong, the problem is your zone file, and no amount of waiting fixes it.
No terminal handy? Our DNS Lookup tool queries A, AAAA, MX, TXT, CNAME, NS, and SOA for any domain via DNS-over-HTTPS, straight from your browser — handy on a phone mid-incident.
Related reading: HTTP status codes for the layer above DNS, URL encoding for what happens to hostnames and query strings, and Unix timestamps for the TTL and SOA timer math.
Try it yourself
Use the free browser-based DNS Lookup on DevBench — no signup, runs entirely in your browser.
Open DNS Lookup