DNS

DNS turns names like example.org into the records computers need — IP addresses (A), aliases (CNAME), mail servers (MX) — through a chain of servers and layers of caches.

Look up www.example.org (A)

Browser
Resolver
Root
.org
Nameserver

example.org zone (on its nameserver)

example.orgA203.0.113.10
www.example.orgCNAMEexample.org
example.orgMX10 mail.example.org
mail.example.orgA203.0.113.25

TTL 3600 s on every record.

www.example.org is an alias (CNAME) for example.org, so the answer comes in two parts.

Step 1 / 7
DNS queries
0
Time (typical)
0 ms
Look up
When

Times are typical round trips, for illustration.

Step by step

The example above, written out — the same steps the animation plays.

  1. 1Look up www.example.org (A). www.example.org is an alias (CNAME) for example.org, so the answer comes in two parts.
  2. 2Ask the resolver. Nothing cached locally: ask the resolver.
  3. 3Ask a root server. There are 13 root server names (hundreds of machines). They only know who runs each top-level domain.
  4. 4Root: try .org. A referral, not an answer.
  5. 5.org: try example.org's nameserver. The .org servers know which nameserver is in charge of example.org (its NS records).
  6. 6The authoritative answer. The nameserver returns the CNAME and, since it also runs example.org, its A record in the same reply.
  7. 7Answer in ~124 ms. The resolver caches every answer for its TTL, so the next person gets it in one hop.

What's happening?

  1. The browser and operating system check their caches first; a cached answer costs nothing.
  2. Otherwise a resolver asks the root, then the .org servers, then the domain's own nameserver — or answers from its cache if someone asked recently.
  3. Every answer carries a TTL saying how long it may be cached; until it expires, changes to the record are not seen.

Complexity

Time
0 queries from cache · up to 4 network queries when nothing is cached
Space
Cached answers on every layer, for their TTL

Where you'll meet it

Pointing a domain at a new server, setting up email (MX), using a CDN (CNAME), and every "it works for me but not for them" after a DNS change.

Common mistake

Changing a record and expecting everyone to see it at once. Old answers stay cached until their TTL runs out — lower the TTL before a planned move.

FAQ

What is a TTL?

Time to live: how many seconds an answer may be cached. 3,600 means caches can reuse it for an hour.

What is the difference between A and CNAME?

An A record gives an IP address; a CNAME says "this name is an alias of that name — look that one up instead".

What is an MX record?

It names the server that receives email for the domain, with a priority. Email follows MX, not the website's A record.