Networking

DNS — Domain Name System

Almost every other page in this domain starts from an IP address already in hand. DNS is the step before that step — the lookup that turns a name a human can remember (example.com) into the numeric address IP actually needs, run automatically, invisibly, before nearly every connection on the internet.

Quick reference
What it is
The distributed lookup system that translates human-readable domain names into IP addresses.
Mental model
A phonebook: you know a name, DNS looks up the number — except the phonebook is split across thousands of independently-run servers instead of one big book.
Key numbers
Port 53; mostly UDP (falls back to TCP for large responses).
Reach for it when
Never directly — it runs automatically the instant any application connects to something by name instead of by raw IP address.

Why names instead of just addresses

An IP address can change — a server gets migrated, a site moves to a new host, a home internet connection gets a new address from its ISP. A domain name stays stable through all of that, as long as its DNS records are updated to point at the current address. Names are also simply easier for a human to remember, type, and trust than a string of numbers.

The domain hierarchy

A domain name reads right to left as a hierarchy, most general to most specific — the opposite direction from how it's typically read aloud:

Root
The unnamed top of the entire system — represented by the invisible trailing dot in example.com..
TLD (Top-Level Domain)
.com, .org, .io — the first real level, managed by a registry for each one.
Domain
example in example.com — registered by an individual or organization.
Subdomain
www or api in www.example.com — created freely by whoever controls the domain, no registration needed.

Resolving a name, hop by hop

Looking up a name for the first time is a chain of "who do I ask next" hops, each server referring the resolver one level further down the hierarchy:

A client asks its resolver, which asks a root server, then a TLD server, then the authoritative server, each one referring it one level further down the hierarchy until the answer comes back Client Resolver e.g. 8.8.8.8 Root "ask .com" .com TLD "ask example.com's NS" Authoritative has the A record "example.com is at 93.184.216.34" — travels back to the client Each hop up top only ever answers "ask this other server next" — only the last one has the actual address. Once answered, the resolver caches the result so this whole chain doesn't repeat for a while.
A cold lookup can take four hops; a cached one (the common case) is answered by the resolver alone, in one step.

Record types

A
Maps a name to an IPv4 address.
AAAA
Maps a name to an IPv6 address.
CNAME
An alias — points one name at another name, which is then resolved in turn.
MX
Which server handles email for this domain — the record SMTP looks up before delivering a message.
TXT
Arbitrary text — commonly used for domain ownership verification and, notably, the SPF/DKIM records SMTP's own gotchas mention as the fix for outbound mail landing in spam.
NS
Which servers are authoritative for this domain — the record a TLD server hands back to point the resolver at the right place.

Caching and TTL

Every DNS record carries a TTL (Time To Live) — how many seconds a resolver is allowed to keep reusing that answer before asking again. This is why most lookups are fast: the four-hop chain above only happens once per TTL window, not on every single request. It's also why changing a DNS record isn't instant — every resolver that already cached the old answer keeps serving it until that cached copy's TTL expires, which is why DNS changes are described as "propagating" rather than taking effect immediately.

Real-world applications

Gotchas

Field notes