{}DSA Atlas

DNS

How a name becomes an IP address — stub, recursive and authoritative resolvers, the root/TLD hierarchy, record types, TTLs and caching, DNS over UDP/TCP/HTTPS, DNS-based load balancing and failover, GeoDNS, anycast, and DNS security.

Beginner → Intermediate6 interview questions

Why DNS exists

Humans remember example.com; networks route 93.184.215.14. The Domain Name System is a globally distributed, hierarchical, heavily cached database that maps names to addresses (and much more). It's also one of the most important pieces of traffic control infrastructure you have.

The hierarchy

. (root) .com .org .in example.com google.com gov.in 13 root server names, ~1,800 anycast instances TLDs zones run by authoritative servers
Each level delegates to the next with NS records.

Resolution step by step

Browser / OSstub resolver Recursive resolverISP / 1.1.1.1 · caches Root server .com TLD server example.comauthoritative 1 8 (A record) 2 ask root 3 "ask .com: NS…" 4 5 "ask ns1.example" 6 7 A 93.184.215.14
The stub asks once (recursive query); the resolver walks the tree (iterative queries) and caches each answer.
Shell
dig www.example.com +trace       # watch the delegation chain
dig example.com MX +short
dig @1.1.1.1 example.com AAAA

Record types

TypeMapsExample
A / AAAAname → IPv4 / IPv6api.example.com. 300 IN A 203.0.113.10
CNAMEalias → canonical namewww → example.com.cdn.net.
ALIAS / ANAMEapex alias (provider feature)example.com → lb-123.elb.amazonaws.com
MXmail exchangers10 mx1.example.com.
TXTtext: SPF, DKIM, DMARC, verification"v=spf1 include:_spf.google.com ~all"
NSdelegationexample.com. NS ns1.dnsprovider.net.
SOAzone authority, serial, negative TTL
SRVservice location with port_xmpp._tcp 10 5 5222 chat.example.com.
PTRreverse DNS10.113.0.203.in-addr.arpa → api.example.com
CAAallowed certificate authorities0 issue "letsencrypt.org"
HTTPS / SVCBconnection hints (ALPN h3, ECH)1 . alpn="h3,h2"

Caching and TTLs

Caches exist in the browser, the OS, the recursive resolver, and sometimes in application runtimes (JVM networkaddress.cache.ttl). Negative answers (NXDOMAIN) are cached too, per the SOA's minimum TTL.

DNS as a traffic-management tool

TechniqueUse
Round robin (multiple A records)crude load spreading
Weighted routingcanaries, gradual migration between stacks/providers
Latency-based / GeoDNSsend users to the nearest region; data residency
Health-checked failoveractive-passive between regions
Anycastone IP, many locations — DNS servers, CDNs, global LBs
Split-horizon DNSdifferent answers for internal vs external clients
Service discoveryConsul DNS, Kubernetes CoreDNS (svc.namespace.svc.cluster.local)

DNS security and failure modes

Threat / failureMitigation
Cache poisoning (forged responses)random source ports + query IDs, DNSSEC (signed records)
On-path snoopingDNS over HTTPS/TLS/QUIC
DDoS on authoritative serversanycast, large providers, multiple providers (secondary DNS)
Domain hijacking / expiryregistrar lock, MFA, auto-renew
Dangling CNAMEs (subdomain takeover)remove records when deprovisioning cloud resources
DNS outage = total outagelong-enough TTLs, multi-provider DNS, don't make every internal call depend on fresh lookups

Interview questions

0 / 6 marked confident

Answer out loud first, then open the model answer. Mark a question confident only when you could explain it to an interviewer without notes.