Skip to main content

Application Layer Protocols

DNS: The Internet Directory

0:00
LearnStep 1/3

Deep Dive into DNS Architecture

The Domain Name System (DNS) is the distributed database that translates human-readable hostnames into IP addresses. For senior engineers, understanding the mechanics of resolution, caching, and record types is critical for debugging latency issues, configuring load balancers, and managing email delivery.

The DNS Hierarchy and Query Types

DNS operates in a hierarchical structure starting from the Root (.), down to Top-Level Domains (TLDs) (like .com, .net), and finally to Authoritative Nameservers for specific domains.

Recursive vs. Iterative Queries

  • Recursive Query: The client (stub resolver) asks the DNS server (usually the ISP's or a public resolver like 8.8.8.8) to do the full lookup and return the final answer. The burden of resolution is on the server.
  • Iterative Query: The server responds with the best answer it knows, typically a referral to another nameserver lower in the hierarchy. The client (or the recursive resolver acting on its behalf) must follow the chain.

Common DNS Record Types

Beyond mapping names to IPs, DNS records serve various infrastructure purposes:

  • A / AAAA: Maps a hostname to an IPv4 (A) or IPv6 (AAAA) address. This is the fundamental 'address' record.
  • CNAME (Canonical Name): Maps a hostname to another hostname (alias). Note: You cannot create a CNAME record for the root domain (APEX record).
  • MX (Mail Exchange): Specifies mail servers for accepting email on behalf of a domain. Includes a priority value.
  • TXT: Stores text notes. Heavily used for verification (SPF, DKIM, Google Site Verification).
  • NS (Name Server): Delegates a DNS zone to use the given authoritative name servers.

TTL and Caching Layers

Time To Live (TTL) dictates how long a record should be cached. Caching occurs at multiple layers:

  1. Browser Cache: Browsers maintain their own short-lived DNS cache (chrome://net-internals/#dns).
  2. OS Cache: The operating system's resolver cache (e.g., nscd on Linux, mDNSResponder on macOS).
  3. Recursive Resolver Cache: ISPs and public DNS providers cache results based on the TTL set by the authoritative server.

Low TTLs (e.g., 60s) allow for rapid failover but increase query load. High TTLs (e.g., 86400s) reduce load but delay propagation of changes.

Practical Debugging with dig

The dig tool is standard for inspecting DNS responses.

bash