Computers on the internet find each other by number, not by name. When you type example.com into a browser, something has to turn that friendly name into a number like 192.0.2.10 before a single byte of the web page can travel. That something is DNS, the Domain Name System. It's the internet's phone book, except no single computer holds the whole book. This page follows one lookup from your keyboard to the answer, and shows why most lookups take almost no time at all.

Names for people, numbers for machines

Every device on the internet is reached through an IP address (IP stands for Internet Protocol). The older and still most common kind, IPv4, is four numbers from 0 to 255 separated by dots, like 203.0.113.7. The newer kind, IPv6, is longer and written in hexadecimal, like 2001:db8::7. Routers, the machines that pass your data along, only understand these numbers.

Numbers are terrible for people, though. They're hard to remember, and they change: a company might move its website to a new server or a new hosting provider, and the address changes with it. So we use domain names instead, and DNS keeps the mapping between the two up to date. You remember the name; DNS remembers the number.

All the addresses on this page are examples. The ranges 192.0.2.x, 198.51.100.x and 203.0.113.x (and 2001:db8:: for IPv6) are officially reserved for documentation, so they never belong to a real machine. Likewise example.com, example.net and example.org are reserved names for examples. The real example.com does exist and has a real address, which can change.

Reading a name from right to left

A domain name is a list of labels separated by dots. People read it left to right, but DNS reads it right to left, from the most general part to the most specific:

A full web address (a URL) has more in it than the name, and that's a common source of confusion. Type any URL below and watch it split into parts. Notice which part DNS actually cares about.

Hostname splitter

Two things to take from the splitter. First, DNS only ever sees the hostname: the scheme (https://), the port (:8080), the path (/blog/post) and the query (?id=7) are used later, by your browser and the web server. Second, some countries use two-label endings like co.uk: you can't register co.uk itself, so in shop.example.co.uk the name you'd buy is example.co.uk. The splitter knows a handful of these; browsers use a long shared list called the Public Suffix List.

The cast: who takes part in a lookup

No single server knows every name on the internet. Instead, the work is split between several kinds of DNS servers, each knowing a small piece and pointing to whoever knows the next piece.

The root and TLD servers don't answer the question. They give a referral: "I don't know, but ask these servers". The resolver follows the referrals down the tree until it reaches someone who knows. Step through a lookup for www.example.com and switch between the cache situations to see how many trips it takes.

Step through a lookup · www.example.com

step 0/0trips over the network 0answer ?

With nothing cached, the resolver makes three separate trips (root, .com, authoritative), plus the trip from your computer to the resolver: four round trips in total, each typically taking somewhere between a few and a hundred-odd milliseconds. With the answer already cached, it's one trip, or zero if your browser remembers. That's the whole trick that keeps DNS fast: almost every lookup is answered from a cache somewhere along the way, and the root servers hear about only a tiny share of the world's lookups.

Records: what the answer actually looks like

An authoritative server stores records: small facts about a name. Each record has a name, a type, a value and a TTL (more on that in a moment). The ones you'll meet first:

TypeMeansExample value
Athe IPv4 address192.0.2.10
AAAAthe IPv6 address2001:db8::10
CNAME"this name is an alias of another name"example.com.
MXwhich server receives email for the domain10 mail.example.com.
NSwhich servers are authoritative for itns1.example.net.
TXTfree text, often used to prove you own a domain"v=spf1 -all"

You can ask DNS yourself from a terminal. On macOS and Linux, the dig tool shows the raw answer; nslookup example.com works on Windows too. An answer line looks like this (illustrative, with a documentation address):

$ dig +noall +answer www.example.com
www.example.com.     3600    IN    A    192.0.2.10

Read it left to right: the name (with its final root dot), the TTL in seconds (3600 = one hour), the class (IN for "internet", almost always), the record type (A), and the address. Run it twice against a caching resolver and the TTL number goes down between runs: you're seeing the cached copy count down.

TTL: how long a cache may remember

Caching makes DNS fast, but it raises a question: if the resolver remembers the answer, how does it ever notice when the address changes? The answer is the TTL, short for time to live. Every record carries one, set by the domain's owner. It says "you may reuse this answer for this many seconds, then you must ask again". When it runs out, the cached copy expires and the next visitor's lookup goes all the way back to the authoritative server.

Choosing a TTL is a trade-off. Below, visitors who share one resolver ask for www.example.com every 5 minutes. The first visitor, at minute 0, makes the resolver fetch and cache the address 192.0.2.10. One minute later the owner moves the site to a new server and changes the A record to 203.0.113.20. Drag the TTL and watch which visitors still get sent to the old, switched-off server.

TTL simulator · one resolver, two hours

TTL30 min
asked authoritativefrom cache, correctfrom cache, old address
0full lookups (trips to authoritative)
0answered from cache
0sent to the old server

A long TTL means fewer lookups and faster answers, but changes take longer to reach everyone. A short TTL means changes spread quickly, at the cost of more lookups. Common settings range from 5 minutes to a day. A trick professionals use: a day or two before moving a site, they lower the TTL to a few minutes, wait for the old long TTL to run out everywhere, make the change, then raise the TTL again afterwards.

This is where the phrase "DNS propagation" comes from. When someone says "wait up to 48 hours for DNS to propagate", nothing is being pushed out to the world. Caches around the internet are simply holding the old answer until their TTLs expire, and each one refreshes on its own schedule.

When DNS goes wrong

Because almost everything online starts with a name lookup, a DNS problem looks like "the internet is broken" even when the network is fine. Some things you might see:

One more thing worth knowing: classic DNS messages travel unencrypted (on port 53, mostly over UDP, a quick no-handshake way to send small messages), so anyone on the network path can see which names you look up. Newer options like DNS over HTTPS wrap the same questions in encryption, and many browsers can turn it on in their settings.

Check yourself

A resolver with an empty cache asks a root server for www.example.com. What does the root server send back?

A referral. The root only knows who runs each top-level domain, so it points the resolver at the .com servers. They in turn point at example.com's authoritative servers, which give the actual address.

You type https://shop.example.com:8443/cart?item=3. Which part is sent to DNS?

Only the hostname. The port 8443 and the path /cart?item=3 are used after the address is known, when your browser talks to the web server itself.

Your A record has a TTL of 3600. You change the IP address. How long might some visitors still be sent to the old one?

TTL is in seconds: 3600 s is one hour. A resolver that cached the old answer just before your change may keep using it for up to that long.

You visit a site, then reload it a minute later. Why is the second lookup so fast?

Your browser, your operating system or your resolver still has the answer from a minute ago, well within its TTL, so no trip to the root, TLD or authoritative servers is needed.

The short version

Next time a page takes a moment to start loading on a site you've never visited, you'll know part of that pause was a little relay race across the internet, just to find out where to go.