Domain name system (DNS)

Understand name resolution, records, caching, and traffic routing.

In this article

The Domain Name System (DNS) translates a name such as www.example.com to an IP address. DNS is hierarchical. A resolver learns which authoritative servers to query, then caches answers for the record's time to live (TTL).

Fig 1Resolve a name, then reuse its answer
STUDY MODEL
Inspect one part at a timeClient cache
  1. Client cache

    Browser or OS caches may already have a usable answer for www.example.com.

  2. Resolver

    On a miss, the client asks a recursive resolver.

  3. Delegations

    A root directs the resolver toward the TLD, which directs it to an authoritative server. The authoritative example returns A: 192.0.2.10.

  4. TTL

    Cache the answer for its applicable TTL. A lower TTL can reduce stale-cache duration but increase lookup traffic.

The recursive resolver makes iterative queries when its cache cannot answer.

How to read this model

A name catalogue beside a cached-address drawer. The object is a teaching analogy. Inspecting a part highlights its role; it does not execute or simulate the software. Cabinet trays are records, workpieces are data, and latches are checks. Unless an explanation states a quantity, compartments and sample workpieces do not denote data counts. Part dimensions are not a quantitative scale.

Concept redrawn from DNS security presentation.

Your router or internet service provider usually supplies the recursive resolver. The browser and operating system may cache the answer too. A low TTL lets changes propagate sooner, but increases lookup traffic. A high TTL reduces lookup traffic, but leaves stale addresses in caches for longer.

Common records

Record Purpose Example
NS Names the authoritative servers for a domain or subdomain. example.com -> ns1.example.net
MX Names mail servers that accept messages. example.com -> mail.example.com
A Maps a name to an IPv4 address. www.example.com -> 192.0.2.10
CNAME Maps a name to another name, which then resolves to an address. example.com -> www.example.com

Managed providers such as Cloudflare DNS and Amazon Route 53 host authoritative DNS and can apply routing policies:

  • Weighted round robin sends a chosen share of requests to each destination. It can balance clusters of different sizes, keep a destination out during maintenance, or support an A/B test.
  • Latency-based routing sends a client to a destination with a measured low network latency.
  • Geolocation-based routing chooses a destination from the client's location.

DNS routing is coarse. Resolvers cache answers, so a changed policy does not affect every client at once. Use a load balancer when you need per-request health checks or fast routing changes.

Costs and failure modes

A cache miss adds a lookup delay, though browser, OS, and resolver caches reduce it. DNS management has several layers of delegation, and public DNS providers themselves can be targets for denial-of-service attacks. If a resolver or authoritative provider is unavailable, clients may fail before reaching the application even when the application is healthy.

Further reading

Keep track of your reading.

Your reading progress stays in this browser.