What really happens when you type a domain name
Not "DNS turns names into IPs". The real path: four caches, one resolver doing all the walking, root → TLD → authoritative referrals, a 12-byte header, TTLs, and the attacks that shaped all of it. Every trace on this page is real output I ran today.
1.1.1.1), which walks the tree for you: the root says "ask .lol", .lol says "ask GoDaddy's servers", and GoDaddy gives the answer. Each reply carries a TTL (how long to remember it), so the next lookup is fast.
- Nobody but the last server knows the answer. Everyone above just points you down (a referral).
- The same lookup took
323 msthe first time and44 msthe second, because of the resolver's cache. - "DNS takes time to update" is really "old answers live in caches until their TTL runs out".
01 · THE NAME IS A TREERead it right to left
system-design.nitesh.lol really ends with a hidden dot: system-design.nitesh.lol. That last dot is the root. Each label to the left is one level down a tree, and each level can be run by a different organisation. This is called delegation.
02 · THE CASTFour kinds of players
| Player | What it does | In my lookup |
|---|---|---|
| Stub resolver | The tiny DNS client in your OS. Asks one question, waits for a full answer. Does no walking. | macOS mDNSResponder |
| Recursive resolver | Does the real work: walks the tree, follows referrals, caches everything. | 1.1.1.1 (Cloudflare) |
| Root / TLD servers | Only give referrals: "I don't know, but these servers handle the next level". | g.root-servers.net, d.nic.lol |
| Authoritative server | Holds the real records for a zone. Its answer is final. | ns04.domaincontrol.com |
The stub sends a recursive query ("give me the final answer"). The resolver sends iterative queries ("tell me what you know"). That difference is the rd (recursion desired) flag in the packet.
03 · BEFORE ANY PACKETFour caches first
Most lookups never leave your laptop. The order:
| # | Where | Look at it |
|---|---|---|
1 | Browser's own DNS cache | chrome://net-internals/#dns |
2 | The hosts file (fixed name → IP list) | /etc/hosts |
3 | OS cache in the stub resolver | macOS: sudo dscacheutil -flushcache clears it |
4 | Recursive resolver's cache, shared with everyone using it | the Query time in dig |
Only when all four miss does the real walk start.
04 · THE WALKFollow the referrals
Click each step. This is exactly what dig +trace system-design.nitesh.lol printed on 10 Nov 2026.
The chicken-and-egg problem: glue records
The .lol servers are called a.nic.lol, which is itself inside .lol. To find them you'd need to ask them first. The fix: the root sends their IP addresses along with the referral, in the ADDITIONAL section. These are glue records. Real output from asking a root server directly:
$ dig +norecurse @a.root-servers.net nitesh.lol A
;; flags: qr; QUERY: 1, ANSWER: 0, AUTHORITY: 4, ADDITIONAL: 9
;; AUTHORITY SECTION:
lol. 172800 IN NS a.nic.lol.
...
;; ADDITIONAL SECTION: <- the glue
a.nic.lol. 172800 IN A 194.169.218.146
a.nic.lol. 172800 IN AAAA 2001:67c:13cc::1:146
Note ANSWER: 0: the root never answers the question, it only points down. And there is no aa flag, because it is not the authority for nitesh.lol.
And who tells the resolver where root is?
Nobody, at runtime. Every resolver ships with a small file of root server IPs, the root hints (IANA's named.root). For example a.root-servers.net is 198.41.0.4. On start-up the resolver asks one of them for the current list (a priming query). That is the first block of the trace: 13 names, a to m.
The CNAME twist
The final answer was not an IP. It was CNAME system-design-drawn.netlify.app.: "this name is an alias, go look up that one". The resolver then starts a new walk for netlify.app and returns both to my laptop:
system-design.nitesh.lol. 3600 IN CNAME system-design-drawn.netlify.app.
system-design-drawn.netlify.app. 120 IN A 13.215.239.219
system-design-drawn.netlify.app. 120 IN A 52.74.6.109
Two TTLs: GoDaddy says "keep my alias for 3600 s", Netlify says "keep my IPs only 120 s" so it can move traffic between servers quickly.
05 · THE PACKETWhat actually goes on the wire
A normal query is one UDP packet to port 53, and one back. No connection set-up, which is why DNS is fast. The message format is from RFC 1035 (1987) and still in use:
QR bit says which one it is.| Flag | Meaning | In my dig output |
|---|---|---|
qr | This is a response | set |
rd | Recursion desired: "please walk for me" | set (I asked the resolver) |
ra | Recursion available: "I can do that" | set by 1.1.1.1 |
aa | Authoritative answer, from the zone's own server | not set: it came from a cache |
tc | Truncated: answer too big for UDP, retry over TCP | not set |
The 512-byte limit, and how we got past it
RFC 1035 limits a UDP DNS message to 512 bytes. Bigger answers set tc, and the client retries over TCP (slower: needs a connection first). EDNS0 (RFC 6891) adds an OPT record where the client says how big a UDP reply it accepts. My dig showed udp: 1232. That number comes from DNS Flag Day 2020: it is small enough to avoid IP fragmentation on almost every network.
06 · CACHING AND TTLWhy "DNS takes time to update"
Every record has a TTL (time to live) in seconds. A resolver keeps it that long, counting down. From my trace:
| Record | TTL | So it is re-asked about every |
|---|---|---|
| root NS list | 518400 (showed 507838 left) | 6 days |
.lol NS | 172800 | 2 days |
nitesh.lol NS, my CNAME | 3600 | 1 hour |
| Netlify A records | 120 | 2 minutes |
This is why root servers are not overloaded: busy resolvers ask them rarely. It is also the real meaning of "propagation": nothing is pushed anywhere. Old answers just sit in thousands of caches until each TTL hits zero. Tip: lower the TTL a day before you plan to change a record.
"No such name" is cached too. For a missing name the server returns NXDOMAIN plus its SOA record, and the resolver caches the "no" for the SOA's last number (RFC 2308). For nitesh.lol that is 600 s. So if you look up a subdomain before creating it, you may see "not found" for 10 minutes after.
system-design.nitesh.lol at a new Netlify site in GoDaddy, and the old page kept showing. DNS was correct: the trace above proves it. The problem was one layer up. Many sites share Netlify's IPs, so Netlify picks the site using the name in the HTTP request (the Host header / TLS SNI). The name was still attached to the old site inside Netlify. DNS only gets you to the building; the building decides which room.07 · ANYCAST13 names, thousands of servers
There are only 13 root names (an old packet-size limit), but per root-servers.org they are served by 2048 machines run by 12 operators (as of 10 Nov 2026). The trick is anycast: many machines around the world announce the same IP, and internet routing sends you to the nearest one. 1.1.1.1 and 8.8.8.8 work the same way. That is why my query to 1.1.1.1 took only 44 ms from India.
08 · ATTACKSWhy DNS got harder over time
Cache poisoning
Plain DNS over UDP has no signature. A resolver accepts the first reply that matches its question and the 16-bit ID. An attacker can flood fake replies, guessing the ID. In 2008 Dan Kaminsky showed how to keep trying with fresh random sub-names until one guess wins, then take over a whole domain. The fix was to also randomise the source port: now an attacker must guess about 16 bits of ID and about 16 bits of port (RFC 5452).
DNSSEC: signed answers
DNSSEC adds signatures (RRSIG records) to answers. Each parent signs a hash of the child's key (a DS record), forming a chain up to the root's key, which resolvers trust in advance (RFC 4033). A forged answer then fails the check. It proves the answer is genuine, but it is still readable by anyone.
Privacy: encrypted DNS
| Fix | What it hides | Spec |
|---|---|---|
DoT (DNS over TLS, port 853) | Your questions, from the network path | RFC 7858 |
DoH (DNS over HTTPS, port 443) | Same, and looks like normal web traffic | RFC 8484 |
| QNAME minimisation | The resolver tells root only lol, not the full name | RFC 9156 |
The TLS handshake inside DoT and DoH uses the same Diffie–Hellman key exchange from yesterday's note.
09 · TRY ITCommands to see all this yourself
dig +trace example.com # the full walk from root
dig example.com # run twice, compare "Query time"
dig +norecurse @a.root-servers.net example.com # a raw referral
dig example.com NS +short # who is authoritative
dig nosuchname.example.com # NXDOMAIN + SOA (negative cache)
dig @1.1.1.1 example.com +tcp # force TCP instead of UDP
SOURCESWhere these facts come from
- Real
dig 9.10.6andopenssloutput, run on my Mac via1.1.1.1, 10 Nov 2026 - RFC 1034 / RFC 1035: DNS concepts, message format, 512-byte UDP limit
- RFC 6891: EDNS0 · dnsflagday.net/2020: the
1232byte default - RFC 2308: negative caching
- root-servers.org: 13 identities, 12 operators, 2048 instances · IANA root hints
- RFC 5452: spoofing defences · RFC 4033: DNSSEC
- RFC 7858 DoT · RFC 8484 DoH · RFC 9156 QNAME minimisation