How DNS Works — Domain Name System & Global Routing Explained
DNS converts names to addresses and can steer users to healthy, nearby regions.
DNS is the internet's phone book. When you type 'google.com', your browser doesn't know what IP address that is — it knows a name. DNS is the system that translates that name to an IP address so your browser knows where to send the request.
The lookup chain: your device checks its local DNS cache → if miss, asks a recursive resolver (e.g. 8.8.8.8) → the resolver asks a root nameserver ('who handles .com?') → asks a TLD nameserver ('who handles google.com?') → asks Google's authoritative nameserver → finally gets the IP. This chain sounds slow but is typically fast because resolvers cache responses aggressively using TTL (Time To Live).
For system design, DNS is more interesting than a simple lookup: it's a global routing layer. GeoDNS returns different IPs based on where the user is — European users get a European data center, US users get a US one. DNS failover can route away from unhealthy regions. Anycast assigns the same IP to servers in multiple data centers, so the network's routing protocol automatically sends users to the nearest one (how Cloudflare works).
Key concepts
Step-by-step approach
- 1
Client sends a DNS query to the OS stub resolver, which checks the local cache first (using TTL from the previous lookup).
- 2
On cache miss, the stub resolver forwards to the configured recursive resolver (ISP, 8.8.8.8, or corporate).
- 3
Recursive resolver walks the DNS hierarchy: root nameserver → TLD nameserver → authoritative nameserver.
- 4
Authoritative nameserver returns the IP address (A record) and a TTL. The recursive resolver caches the response for TTL seconds.
- 5
For multi-region deployments, configure GeoDNS to return different A records based on the client's geographic location, or use Anycast for automatic nearest-server routing.
Key trade-offs
Short TTL vs. long TTL
Short TTL (60s) enables fast failover — DNS propagates quickly when a server goes down. Long TTL (3600s) reduces resolver load and speeds up lookups for users. Design around your failover requirements.
GeoDNS vs. Anycast
GeoDNS is application-level routing (you control what IP each region gets). Anycast is network-level routing (BGP automatically routes to the nearest server sharing the same IP). Anycast is harder to set up but more resilient.
DNS-based load balancing vs. L7 load balancing
DNS round-robin is simple but doesn't health-check. L7 load balancers health-check and route only to healthy backends. Use both layers for production reliability.
Common pitfalls
Not accounting for DNS caching in failover: even with a 60s TTL, some resolvers and clients ignore TTL and cache longer. Plan for 5-15 minutes of propagation time.
Using DNS as the only layer of load balancing: DNS returns IPs equally but doesn't know which backend is under load. Combine with a real load balancer.
Forgetting negative TTL: a failed DNS lookup is also cached (for the negative TTL period), causing repeated failures even after you fix the issue.
Interview questions on this topic
Practice answering these with AI feedback → Start on CrackLab
Continue learning — explore 207 more topics on CrackLab DesignHub
From Classic HLD designs (Twitter, YouTube, Uber) to LLD patterns, distributed systems, databases, and company case studies.
Related topics
A request moves from browser to DNS, TCP, TLS, HTTP, load balancer, app, storage, and back.
Move static and cacheable content close to users to reduce latency and origin load.
Distribute traffic across healthy backends using L4/L7 algorithms and health checks.