Opscraft
How DNS works behind the scenes · Lesson 1 of 9 · 3 min read

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

Enlarge diagram.cominorgexampleco.inwwwapiroottop-level domainsdomains (zones)hostnamesFull name, right to left: api . example . com . (root)
Figure 1. The DNS namespace is a tree read right to left: api.example.com. sits under example, under com, under the root ("."). Each level can be handed off (delegated) to different servers.
Swipe sideways to see all of it, or tap to open it full screen.

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
Enlarge diagramStubresolverin your OSRecursiveresolverwalks the tree,cachesRoot serverswhich TLD servers?TLD servers (.com)which name servers?Authoritativethe actual recordasks once, waits
Figure 2. The servers involved in one lookup. Your machine only talks to the recursive resolver; the resolver does the walking.
Swipe sideways to see all of it, or tap to open it full screen.