Skip to the workspace
Pebellslearn by building
How the Web Works  ›  Lesson

Domain Names and DNS

DNS and how it works? 14 minA domain name is a human-friendly label read from right to left, and DNS resolves it to an IP address by asking root, top-level-domain and authoritative servers, caching each answer for its TTL.

backend / Domain Names and DNS

Explore each scene at your own pace.

01 · The rule

The rule

Domain Names and DNS

Nobody wants to type 203.0.113.10 to buy a book. People remember bookshop.example, but packets only understand IP addresses. The Domain Name System (DNS) is the internet's phone book, and when a deploy "works for me but not for them", DNS is often the reason.

The rule

Names are for people; DNS turns them into addresses.

A domain name is read from right to left, from the most general part to the most specific:

  • example in api.bookshop.example is the top-level domain (TLD), like .com, .org or .in. (.example itself is reserved for examples like ours.)
  • bookshop.example is the domain you rent every year from a registrar.
  • api.bookshop.example is a subdomain. Once you own the domain, you can create as many as you like.

A domain's authoritative name server holds its records. The common ones:

Record Points a name at
A an IPv4 address
AAAA an IPv6 address
CNAME another name (an alias)
MX the mail servers for the domain
TXT free text, often used to prove you own the domain

Every record has a TTL (time to live) in seconds: how long others may cache the answer before asking again.

dig api.bookshop.example A

A typical answer line reads api.bookshop.example. 300 IN A 203.0.113.10: the name, a TTL of 300 seconds, and the address.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.