DNS (Domain Name System) translates human-readable names into IP addresses. It’s one of the oldest and most critical parts of internet infrastructure, and most developers interact with it without really understanding it.
Record Types That Matter
A and AAAA Records
Map a domain to an IP address:
example.com. A 93.184.216.34
example.com. AAAA 2606:2800:220:1:248:1893:25c8:1946
A records point to IPv4 addresses. AAAA records point to IPv6. You should have both.
CNAME Records
Alias one domain to another:
www.example.com. CNAME example.com.
blog.example.com. CNAME my-blog.pages.dev.
A CNAME says “go look up this other name instead.” They can’t coexist with other record types at the same name (except in Cloudflare’s flattened CNAME implementation).
MX Records
Route email:
example.com. MX 10 mail1.example.com.
example.com. MX 20 mail2.example.com.
Lower priority number = preferred server. Get these wrong and you don’t receive email.
TXT Records
Store arbitrary text. Used for verification and email authentication:
example.com. TXT "v=spf1 include:_spf.google.com -all"
SPF, DKIM, and DMARC records are all TXT records. They prevent email spoofing.
TTL (Time to Live)
TTL tells resolvers how long to cache a record:
example.com. 300 A 93.184.216.34
300 means resolvers will cache this for 5 minutes. After that, they’ll query the authoritative server again.
- Low TTL (60-300s): Fast propagation for changes. Higher query load.
- High TTL (3600-86400s): Less query load. Slow to update.
Before making DNS changes, lower the TTL first and wait for the old TTL to expire. Then make your change. Then raise the TTL again.
Propagation
“DNS propagation” is really “cache expiration.” When you update a record, resolvers worldwide still have the old record cached. They’ll serve the old record until their cache expires (based on the previous TTL).
This is why lowering TTL before changes matters. If the old TTL was 24 hours, some users will see the old record for up to 24 hours after your change.
Common Mistakes
- CNAME at the apex. Standard DNS doesn’t allow
example.com CNAME something.else.com. Use Cloudflare’s CNAME flattening or an ALIAS record. - Forgetting AAAA records. IPv6 is real and some users are IPv6-only.
- Missing email records. No MX + no SPF = your domain is an open relay for spammers.
- Sky-high TTLs before a migration. Lower TTL days before the change, not during.
- Trailing dots. In zone files,
example.com.(with dot) is absolute.example.com(without) is relative to the zone. Most managed DNS UIs handle this for you.
DNS isn’t glamorous, but getting it wrong breaks everything. Understand the basics and you’ll avoid hours of debugging.