Module 066 min

Names and numbers

Two services do most of the invisible work of the internet: one turns names into addresses, the other hands out addresses in the first place. Most "the internet is down" tickets are one of them.

After this module
  • You can describe what happens between typing a domain and getting an address, including where the caching happens.
  • You can explain why one person sees a new website and another sees the old one, and why a device with a 169.254 address is a DHCP failure.

You type example.com and press enter. Your machine cannot route to a name; it needs a number. Everything that happens in the next few milliseconds is a distributed lookup with several layers of memory, and every layer sets how long a change takes to reach the world.

6.1DNS is a hierarchy with caches

Nobody holds the whole list. The system is a tree, and a resolver walks it.

The four answers behind one lookup.
StepWho answersWhat they say
1. CacheYour browser, then your OS"I already know this, here it is" — or nothing
2. ResolverYour provider, or 1.1.1.1 / 8.8.8.8"Let me find out" — and caches the result
3. RootThe root servers"Ask the servers for .com"
4. TLDThe .com servers"Ask the authoritative server for example.com"
5. AuthoritativeWhoever runs the domainThe actual record, with a TTL

The TTL is the number that decides how quickly a change propagates. A 300-second TTL means stale answers live for at most five minutes. A 24-hour TTL means a mistake this morning follows you into tomorrow.

Try it · same name, two experiences2 cases

Nothing known. The resolver walks root → TLD → authoritative, then returns the record. That is four network round trips instead of none, and the first visitor after a cache expiry pays for all of them.

What this explains: why the very first request to a new service is slow, and why DNS is a latency source you can remove with caching rather than bandwidth.

6.2The records that matter

RecordMeansCommon mistake
AThis name has this IPv4 addressPointing at a load balancer's old IP
AAAAThe IPv6 equivalentMissing, so IPv6 clients fall back slowly
CNAMEThis name is an alias for another nameUsing one at the apex of a zone, where the standard forbids it
MXWhere mail for this domain goes, by priorityPointing at a hostname without an A record
TXTArbitrary text: SPF, DKIM, verificationTwo SPF records, which invalidate both
NSWhich servers are authoritative for the zoneChanging these without changing the zone at the same time
PTRReverse: address to nameExpecting it to match the forward record automatically
dig example.com +short            # the address
dig example.com A +noall +answer  # the record, with its TTL
dig +trace example.com            # walk the hierarchy yourself
dig @1.1.1.1 example.com          # ask a specific resolver

Two resolvers disagreeing is normal and diagnostic: it tells you which cache is stale. Two authoritative servers disagreeing is a misconfiguration, and it produces intermittent failures that move as caches expire at different times.

6.3DHCP: joining a network

Before a device can use DNS it needs an address. DHCP provides one, along with the gateway and the resolver list, in four messages.

DHCP · FOUR MESSAGES client dhcp server 1 · discover — to everyone, because I have no address 2 · offer — here is 192.168.1.50 for 24 hours 3 · request — I would like that one, formally 4 · acknowledge — it is yours, plus gateway and DNS
Discover and request go to everyone, because the client has no address yet. That is why a DHCP server must share the segment, or have a relay pointing at it.
The trap · a full scope looks like a broken network

When a DHCP pool runs out, new devices get no address and self-assign one starting with 169.254. Existing devices keep working, so half the office is fine and the other half "cannot connect". Nothing in the network is broken; the pool is empty. Check the lease count before you check a single cable — and remember that a 24-hour lease on a 100-address pool breaks on the day 120 people bring laptops.

6.4One more number: the port

An address gets you to the machine. A port gets you to the service. The destination port names what you want (443 for HTTPS, 53 for DNS, 5432 for PostgreSQL); the source port names your side of the conversation.

This is why a server can run a web app, an API and an admin console on one address: three ports, three listeners. It is also why "the server is up but the site is down" is a coherent statement — the machine answered, the port did not.

Check yourselfQuestion 1 of 1

You moved a site to a new server an hour ago. Some people see the new site, others see the old one. Why?

60-second recap

  • DNS is a tree with caches. TTL decides how long a mistake lives.
  • 169.254 means no DHCP. The address is a diagnosis, not a configuration.
  • Ports name services. Address reaches the machine; port reaches the thing on it.