DNS, From Query to Answer

How a name becomes an address — resolvers, the root/TLD/authoritative hierarchy, the record types that matter, and why DNS changes take time.

· 2 min read · beginner

DNS is the internet's phone book: it turns names people remember into addresses machines route to. Here's how a lookup actually resolves.

The players

  • Stub resolver — the tiny client in your OS that asks on your behalf.
  • Recursive resolver — does the legwork (your ISP's, or 1.1.1.1 / 8.8.8.8). It caches aggressively.
  • Authoritative servers — hold the real answers for a zone, arranged in a hierarchy: root → TLD (.com) → the domain's own servers.

The walk (when nothing is cached)

text
you ─▶ recursive resolver:
        ├─▶ root server:     "who runs .com?"      ◀─ "ask the .com servers"
        ├─▶ .com server:     "who runs example.com?" ◀─ "ask ns1.example.com"
        └─▶ ns1.example.com: "A record for example.com?" ◀─ "93.184.216.34"
you ◀─ 93.184.216.34

The resolver starts at the top and is referred downward until it reaches the server authoritative for the domain, which gives the real answer. Then it caches it, so the next lookup skips most of this.

Record types worth knowing

TypeAnswersExample use
AIPv4 addressexample.com → 93.184.216.34
AAAAIPv6 addressthe v6 equivalent
CNAMEan alias to another namewww → example.com
MXmail serverswhere email for the domain goes
NSthe domain's authoritative serversdelegation
TXTarbitrary textSPF, domain verification

TTL and why changes are slow

Every record has a TTL (time to live) — how long resolvers may cache it. Set a record's TTL to 3600 and the world may keep the old value for up to an hour after you change it. That's why DNS changes "take time to propagate": you're waiting for caches to expire.

See it yourself with dig

bash
dig example.com A +short       # just the address
dig example.com MX             # mail servers
dig +trace example.com         # watch the whole root→TLD→authoritative walk
dig @1.1.1.1 example.com       # ask a specific resolver

+trace is the one to internalise — it literally prints each referral step described above.

A note on privacy and security

Classic DNS is unencrypted, so your network can see every name you look up. DNS over HTTPS/TLS (DoH/DoT) encrypts those queries. And DNSSEC cryptographically signs records so a resolver can detect tampering — useful to understand even where it isn't yet deployed.

Takeaways

  • A lookup walks root → TLD → authoritative, then the resolver caches the answer.
  • A records map to IPv4, AAAA to IPv6, plus CNAME/MX/NS/TXT for aliases, mail, delegation and text.
  • TTL controls caching — lower it before planned changes so they take effect fast.
  • dig +trace shows the whole resolution; DoH/DoT and DNSSEC add privacy and integrity.

Related

Networking beginner

Subnetting Without a Calculator

CIDR notation demystified. Learn the handful of powers of two that let you split and size networks in your head, with a reference table you'll actually remember.

· 1 min read
Networking beginner

What Happens When You Load a URL

The full journey from pressing Enter to seeing a page — DNS, TCP, TLS and HTTP — tied together so every layer finally makes sense.

· 2 min read