Archprimer
ConceptBeginner 6 min read

DNS

The internet's naming system that resolves human-readable domains to IP addresses via recursive and authoritative resolvers, records, and TTL-based caching.

networkingresolutioncachingroutinginfrastructure

By Ratish Jain · Updated

Diagram with 4 components: Client, Recursive Resolver, Root / TLD, Authoritative NS. Connections: Client → Recursive Resolver (1 · query); Recursive Resolver → Root / TLD (2 · refer); Recursive Resolver → Authoritative NS (3 · resolve); Recursive Resolver → Client (4 · A record).
ClientServiceExternal
A recursive resolver walks the hierarchy to find the authoritative answer.

Definition

The Domain Name System (DNS) is the internet's distributed directory that translates human-readable domain names like example.com into machine IP addresses. It is a hierarchical, globally cached lookup service that runs before almost every network connection.

Why It Exists

People remember names, but machines route on IP addresses that change over time and vary by region. DNS provides a stable, human-friendly layer of indirection: operators can move a service to a new IP or add servers, and clients keep using the same name. It also enables traffic steering and failover without changing what users type.

How It Works

A client asks a recursive resolver, which resolves the answer on its behalf. If not cached, the resolver walks the hierarchy: the root servers point to the TLD servers (like .com), which point to the domain's authoritative nameservers that hold the actual records. Common records: A (IPv4), AAAA (IPv6), CNAME (alias to another name), MX (mail), and NS (delegation). Every answer carries a TTL, so resolvers and OS caches reuse it until it expires, keeping most lookups local. GeoDNS returns different IPs based on the client's location to route users to the nearest region.

What It's Used For

  • Resolving domain names to server IPs
  • Directing users to the nearest data center via GeoDNS
  • DNS-based load balancing and failover
  • Mapping mail (MX) and service (SRV) endpoints
  • Pointing at CDN edges through CNAME chains

Tradeoffs

Pros
  • Human-friendly, stable naming over changing IPs
  • Massively cached and hierarchical, so it scales globally
  • Enables geo-routing, failover, and load distribution
  • Decouples clients from infrastructure changes
Cons
  • TTL caching delays propagation of changes
  • Adds a resolution round trip before the first connection
  • Plain DNS is insecure (spoofing) without DNSSEC/DoH
  • Coarse-grained load balancing — no real-time health awareness

When to Use / Avoid

Use when
You need name-to-IP resolution, geo-routing, or coarse failover — effectively always, for any hosted service.
Avoid when
You need instant cutover or fine-grained, health-aware balancing — rely on a load balancer, not low TTLs alone.
Real-world
Route 53, Cloudflare DNS, and Google Public DNS (8.8.8.8) resolve billions of queries daily.

Interview Questions

Why can a DNS change take time to propagate?

Because resolvers and OS caches hold the old record until its TTL expires. Lowering the TTL before a planned change shortens the window, but you can't force every cache worldwide to drop instantly.

What's the difference between a recursive and an authoritative resolver?

A recursive resolver does the legwork of querying the hierarchy on the client's behalf and caches results. An authoritative nameserver holds the definitive records for a zone and returns the final answer.

60-Second Revision
  • →Maps domain names to IPs via a hierarchical lookup.
  • →Recursive resolver walks root → TLD → authoritative servers.
  • →Records: A, AAAA, CNAME, MX, NS.
  • →TTL-based caching makes it fast but delays propagation.
  • →GeoDNS routes users to the nearest region.

Related

Everything on Archprimer is connected — follow the graph.