Lesson 2 of 15
4. DNS

4.1 Why do we need names at all?

3 min read+10 XP

In your phone's contacts: You could dial numbers from memory, but you'd forget them, mistype them, and every time a friend changed numbers you'd have to learn a new one. Names are for people; numbers are for the phone network.

In the system: Every machine on the internet is reached by an IP address: an IPv4 address like 203.0.113.20 (32 bits) or an IPv6 address like 2001:db8::20 (128 bits). Names solve three problems:

  • Memory: shop.example.com is easier than a string of numbers.
  • Change: the bookstore can move to new servers with new IP addresses, and users still type the same name. Only the DNS record changes.
  • Many machines behind one name: one name can point to several IP addresses, or different ones in different countries (4.6). A single number can't do that.

DNS, exactly: a distributed system that answers questions like "what's the IP address for this name?", where no single server holds all the answers. The data is split across millions of servers, each authoritative for its own part.

Memory code: "Names for people, numbers for machines."