The actors and the namespace
"How does DNS work in the backend?" is a favourite interview question, usually as part of "what happens when you type a URL". A strong answer goes beyond "it turns names into IPs": it walks the full resolution path — stub resolver, recursive resolver, root, TLD, authoritative — explains caching at every layer, shows it with dig +trace, and then applies it to real systems: Linux resolution order, the VPC resolver, CoreDNS in Kubernetes with its ndots:5 behaviour, and the security problems DNS is famous for.
What DNS does
The Domain Name System is a globally distributed, hierarchical, cached database. It maps names to data: IP addresses (A/AAAA), aliases (CNAME), mail servers (MX), text (TXT), service locations (SRV) and more. No single server knows everything — knowledge is split by delegation, and answers are reused through caching.
The namespace tree
A fully qualified domain name (FQDN) ends with a dot for the root: api.example.com. — usually omitted in browsers, but significant in zone files and Kubernetes (ndots behaviour).
The four kinds of servers in a lookup
| Role | What it does | Examples |
|---|---|---|
| Stub resolver | The DNS client library in your OS/app; asks a recursive resolver and waits for a final answer | glibc resolver, systemd-resolved stub, Windows DNS Client |
| Recursive resolver | Does the full lookup on the client's behalf, follows referrals, caches | ISP resolvers, 8.8.8.8 (Google), 1.1.1.1 (Cloudflare), 9.9.9.9, Route 53 Resolver in a VPC, corporate resolvers |
| Root servers | Know which servers handle each TLD | a.root-servers.net … m.root-servers.net |
| TLD servers | Know which servers are authoritative for each domain under the TLD | .com/.net (Verisign), .in (NIXI's registry), .org |
| Authoritative servers | Hold the actual records for a zone and answer definitively | Route 53 hosted zones, Cloudflare DNS, BIND |