How DNS Works: Queries, Caching, TTL and Propagation
From the browser to the authoritative server: how a DNS query travels, recursive vs iterative, and why propagation is just cache and TTL expiring.
The last time I changed a domain's A record, the new site showed up for me instantly and stayed on the old server for half the team for almost a full day. The usual suspect appeared in the chat: "must be DNS propagation". Except there is no propagation in the magical sense people imagine. What happened was cache expiring at different rates in different resolvers, each one honoring the TTL the record had when it was looked up.
This post explains how DNS works from the point of view of a single query: the path from the browser to the authoritative server that holds the answer, the difference between recursive and iterative queries, and why caching at every layer explains almost everything that looks mysterious. If you want the end-to-end view — DNS, TCP, TLS and HTTP together — it is in what happens when you type a URL.
How DNS works in 5 steps
The summary, before the detail:
- Local cache first. The browser and the operating system check their own cache. If the answer is there and the TTL hasn't expired, done: no packet leaves the machine.
- Recursive resolver. With no local cache, the system asks the configured resolver (your ISP's,
1.1.1.1,8.8.8.8). If it has the answer cached, it returns it immediately. - Root. If the resolver doesn't even know who runs
.com, it asks a root server, which answers with the TLD's servers. - TLD. The
.comserver answers with the domain's nameservers (the delegation). - Authoritative. The domain's nameserver returns the requested record. The resolver caches every answer for its TTL and hands the IP back to the system.
browser / OS ──(cache?)──> recursive resolver ──(cache?)──┐
│ iterative queries
┌─────────────────────────────────────────────┘
├──> root (.) "ask the .com servers"
├──> TLD (.com) "ask hera.ns.cloudflare.com"
└──> authoritative "example.com A 104.20.23.154, TTL 300"
Steps 3 and 4 rarely happen for real. The .com delegation comes from the root with a TTL of 172,800 seconds (2 days), so any resolver with some traffic already has the .com servers cached. The full chain is only walked the first time, with an empty cache.
The players in the chain
Stub resolver is the minimal client inside the operating system. It can't resolve anything on its own; it just asks a bigger resolver and accepts the answer. It is what sits behind functions like getaddrinfo.
Recursive resolver is the workhorse. It takes responsibility for chasing down the full answer for you, server by server, and keeps the cache that serves thousands of clients.
Root servers sit at the top of the hierarchy. They don't know example.com's IP, but they know who runs each TLD. There are 13 identities, a.root-servers.net through m.root-servers.net, each with one IPv4 and one IPv6 address, run by 12 independent organizations. Behind those addresses is anycast: root-servers.org counted 2,048 operational instances on November 9, 2026. "13" is a historical limit on addresses, not on machines.
TLD servers handle each top-level domain: .com, .org, .br. The .com server doesn't know example.com's IP either, but it knows the domain's nameservers.
Authoritative server holds the truth: it hosts the zone and returns the record. What lives inside the zone — A, AAAA, CNAME, MX, TXT — is covered in DNS record types; the difference between who delegates and who answers, in nameserver vs DNS zone.
Recursive vs iterative queries: who does the heavy lifting
The query between the stub and the resolver is recursive: "give me the finished answer". The queries the resolver sends to the root, the TLD and the authoritative server are iterative: each one answers "I don't know, but ask so-and-so", with a referral to the next level.
You can watch the chain with dig +trace, which plays the resolver's role and shows each hop. I ran it in a Linux container (BIND 9.18) on November 9, 2026; the output below is trimmed to two records per level:
dig +trace -4 +nodnssec example.com A
. 518400 IN NS a.root-servers.net.
;; Received 811 bytes from 198.41.0.4#53 (a.root-servers.net)
com. 172800 IN NS a.gtld-servers.net.
;; Received 864 bytes from 192.5.5.241#53 (f.root-servers.net)
example.com. 172800 IN NS hera.ns.cloudflare.com.
;; Received 359 bytes from 192.52.178.30#53 (k.gtld-servers.net)
example.com. 300 IN A 104.20.23.154
;; Received 72 bytes from 108.162.192.162#53 (hera.ns.cloudflare.com)
Look at the TTLs: the root server list (6 days), the root delegating .com (2 days), .com delegating example.com (2 days), and only the final A record has a short TTL (5 minutes), because that one is set by the domain owner. For a normal lookup, without the step-by-step:
dig example.com A +short
nslookup example.com # works on Windows too
Caching at every layer: where "propagation" lives
Every player caches answers for the record's TTL (time to live). If the A record has a TTL of 3600, the resolver keeps that IP for an hour and won't ask again during that time.
When you change a record, the authoritative server has the new value immediately. But every resolver in the world keeps serving the old value until its own TTL expires, and since each one looked it up at a different moment, they expire at different moments. Some people see the new value, some see the old one, for up to one TTL. Nothing is spreading across the network: it is cache expiring. The distinction matters because it changes what you can do about it.
The cache doesn't stop at the resolver. The operating system has its own, the browser has its own. That's why you, having flushed your local cache, see the new site while your colleague is still on the old one.
Two cases break the "wait for the record's TTL" rule:
Changing nameservers. Here what counts is the TTL of the delegation in the parent zone, which the domain owner doesn't control. In .com it is 172,800 seconds (the 2 days in the trace above); for a .com.br I measured 3,600 seconds. Lowering the TTL inside your zone does not speed this up. The step-by-step to change nameservers without taking down site and email is in nameserver vs DNS zone, and practical timelines per type of change are in the guide on pointing a domain to your hosting.
Negative caching. A "this name doesn't exist" (NXDOMAIN) is cached too. Per RFC 2308, the duration is the lower of the zone's SOA record TTL and its MINIMUM field. For example.com, both are 1,800 seconds. If you looked up a subdomain before creating it, the resolver may keep saying it doesn't exist for up to half an hour.
Lower the TTL before you migrate
If "propagation" is cache expiring, the preparation is obvious and almost nobody does it: reduce the TTL ahead of time. A couple of days before a planned migration, drop the record's TTL to 300 seconds. Wait for the old TTL to expire (if it was 86400, wait a full day). From then on, every resolver holds the record for at most 5 minutes.
When you make the real switch, the inconsistency window shrinks from hours to minutes. Once things settle, raise the TTL again to cut down repeated lookups. This applies to records inside the zone; for nameserver changes, the delegation timelines above apply.
At the end of the chain, what comes back is an IP. It is worth looking at, because it confirms where the domain actually points, regardless of what the registrar's panel says: drop the address into an IP address info tool to see who owns it and where it is hosted.
UDP, TCP and encrypted transports
By default, DNS runs over UDP on port 53: question, answer, done. When the answer doesn't fit in the packet, the server marks the response as truncated (the TC bit) and the client retries over TCP, also on port 53. DNSSEC-signed answers and large record sets are the usual cases. RFC 7766 makes TCP support mandatory for DNS implementations. The difference between the two protocols is covered in TCP vs UDP.
A traditional query travels in plain text: anyone on the path can see which domains you look up. DoT (DNS over TLS, RFC 7858) uses TLS on port 853, and DoH (DNS over HTTPS, RFC 8484) wraps the query in HTTPS on port 443, mixed in with web traffic. The root, TLD and authoritative chain doesn't change; only the leg between you and the resolver is encrypted.
Frequently asked questions
How long does DNS "propagation" take?
For a record inside the zone (A, CNAME, MX), up to the TTL that was active when you made the change: with a TTL of 86400, some resolvers serve the old value for up to 24 hours. For a nameserver change, the limit is the delegation TTL at the TLD, which in .com is 48 hours. You can't force the world to forget faster; you can lower the TTL beforehand.
Recursive vs iterative query: what's the difference?
In a recursive query, the client asks for the final answer and the server (the resolver) takes care of finding it. In an iterative query, each server answers with what it knows or with a referral to the next server to ask. The stub sends recursive queries to the resolver; the resolver sends iterative queries to the root, the TLD and the authoritative server.
Why does the new site load for me but not for my colleague?
Cache. Your system, browser or resolver already fetched the new value, while your colleague's is still within the TTL window — or they use a different resolver that looked it up at a different moment. Flushing the machine's DNS cache or testing with another resolver usually sorts it out for whoever is testing.
Does changing my computer's DNS server speed up browsing?
Sometimes. A faster or closer resolver answers sooner for lookups that aren't cached. Once a record is cached, the gain disappears. The effect is more noticeable for people who visit many different domains than for those who stay on the same sites all day.
DNS is a chain of caches with expiry dates
A DNS query starts at the local cache, goes to the recursive resolver and, only when it doesn't know, walks down through root, TLD and authoritative server, caching each answer for its TTL. What people call propagation is that cache expiring at different rates. To change a record without surprises, lower the TTL ahead of time; to change nameservers, plan around the delegation TTL, which isn't yours. And when something looks off, dig +trace shows which link of the chain is giving a different answer.
- 01 CPU Cores vs. Threads: What Actually Changes in Practice Understand the difference between CPU cores and threads and what actually changes for performance, multitasking, gaming, and development.
- 02 MIT, Apache, and GPL Licenses: Practical Differences for Developers MIT, Apache 2.0, and GPL are not the same thing. Understand permissive vs copyleft, patent protection, and compatibility before shipping code to production.