← Back to the map

Unit 1 · Lesson 2

DNS

You type shop.example.com. Your computer has no idea where that is. A fraction of a second later it has an address on the other side of the world. Who did it ask?

By the end you can

Watch

Prefer reading? The same lesson is written out below.

Computers find each other by IP address. People remember names. The Domain Name System (DNS) bridges the two: it turns a name like shop.example.com into an address like 203.0.113.7, on demand, for billions of names run by millions of different owners.

The lookup

No single server knows every name. DNS is a tree, and a resolver (usually run by your internet provider, or a public one like 1.1.1.1 or 8.8.8.8) walks it for you:

connect to IPBrowserResolverRoot.com serversAuthoritativeWeb server
A browser asks a DNS resolver for an address. The resolver asks a root server, then the .com servers, then the site's authoritative server, and returns the IP address. The browser then connects to the web server.
  1. Your browser asks the resolver: "Where is shop.example.com?"
  2. The resolver asks a root server: "Who handles .com?" The root points to the .com servers.
  3. It asks the .com servers: "Who handles example.com?" They point to that domain's authoritative server.
  4. It asks the authoritative server, which gives the actual address.
  5. The resolver hands the address to your browser, which connects to it.

Caching makes it fast

Walking the tree every time would be slow, so every answer comes with a TTL (time to live), say 300 seconds. Your browser, your operating system and the resolver all cache the answer until the TTL runs out. Most lookups are answered from a cache in a millisecond or two.

The catch: if you change where a name points, people with a cached answer keep going to the old address until their TTL expires. Before a planned move, teams lower the TTL ahead of time (at least one old TTL before the move), so the switch takes effect in minutes instead of hours.

Record types worth knowing

RecordMaps a name to...
Aan IPv4 address
AAAAan IPv6 address
CNAMEanother name (an alias), e.g. www.example.com → example.com
MXthe mail servers for a domain
NSthe authoritative name servers for a domain

DNS can also do simple load spreading: return several addresses, or different answers depending on where the user is (that's how many CDNs send you to a nearby server).

Key idea: a resolver walks root → top-level domain → authoritative server to find an address, and everyone caches the answer for its TTL. Short TTLs mean faster changes; long TTLs mean fewer lookups.

Check yourself

A resolver has nothing cached. Put its steps in order.

  1. 1Return the IP address to the browser
  2. 2Ask example.com's authoritative server for the address
  3. 3Ask the .com servers who handles example.com
  4. 4Ask a root server who handles .com

Your new flashcards

Practice them now. With a free account they come back in your daily review.

Card 1 of 3