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.
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)
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.34The 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
| Type | Answers | Example use |
|---|---|---|
| A | IPv4 address | example.com → 93.184.216.34 |
| AAAA | IPv6 address | the v6 equivalent |
| CNAME | an alias to another name | www → example.com |
| MX | mail servers | where email for the domain goes |
| NS | the domain's authoritative servers | delegation |
| TXT | arbitrary text | SPF, 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
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 +traceshows the whole resolution; DoH/DoT and DNSSEC add privacy and integrity.