Nothing on the network actually knows what 'api.example.com' means — every request starts by translating it into an IP address through a chain of servers, cached at every step. What actually happens between typing a URL and the first packet leaving your machine.
3 min read
Routers only understand IP addresses, not names — example.com means nothing to
any router along the path. DNS (Domain Name System) is the lookup that turns
a human-readable name into the IP address routing actually needs, and it's the
very first thing that happens before any HTTP request can even be attempted.
No single server holds every domain's IP address. Instead, DNS is a hierarchy,
and answering api.example.com means asking increasingly specific servers:
In practice this whole chain usually takes single-digit milliseconds and is invisible — but it's a real network round trip (or several) before your actual request can even begin, which is exactly why caching (next section) matters so much for perceived speed.
example.com -> 93.184.216.34)www.example.com -> example.com) — cannot coexist with other records on the same name, a common source of confusing DNS errors# dig is the standard tool for inspecting DNS records directly
$ dig example.com A +short
93.184.216.34
$ dig example.com MX +short
0 .Every DNS record has a TTL (time to live) — how long a resolver is allowed to
cache the answer before asking again. A record with TTL 3600 can be cached for
up to an hour; anyone who looked it up 5 minutes ago will keep using the old
answer for up to 55 more minutes, even after you change it.
This is why "I updated my DNS but nothing changed" is almost always just caching, not a mistake — and why a real migration plan lowers the TTL in advance (hours or a day before the actual cutover) so the old, short TTL is already what's cached everywhere by the time you flip the record, letting the change actually propagate quickly instead of waiting out the old long TTL.
A slow or repeatedly-uncached DNS lookup adds real, visible latency before a
request can even start — this is why browsers, operating systems, and public
resolvers like Cloudflare's 1.1.1.1 all cache aggressively, and why some
sites intentionally use very short-lived subdomains sparingly (each first lookup
costs a fresh round trip).
nslookup/dig timing something like this reveals it directly:
$ dig example.com +stats | grep "Query time"
;; Query time: 14 msecBecause everything starts with DNS, it's also a single point of failure and a target: DNS spoofing/cache poisoning attacks try to trick a resolver into caching a wrong (attacker-controlled) IP for a real domain — the reason HTTPS (covered later in this domain) matters even when DNS itself is compromised, since a spoofed IP still can't produce a valid certificate for the real domain. On the reliability side, a DNS provider outage (these happen to major providers a few times a year) can take down sites that are otherwise perfectly healthy — their servers are fine, but nobody can find their address anymore.
Check your understanding
A quick comprehension check — not tracked, not graded, just for you.
1. Why does updating a DNS record not take effect for everyone instantly?
2. What's the practical restriction on using a CNAME record?
3. Why does HTTPS still protect you even if a DNS cache-poisoning attack tricks a resolver into returning a wrong IP?
Networking Fundamentals