AP® Computer Science Principles · Big Idea 4 · Topic 4.1

DNS: Turning a Name into an Address

DNS is the lookup system that translates a human-readable domain name into the numeric IP address a computer actually needs to connect to a server.

Every machine on the internet is reached by an IP address, a number like 93.184.216.34. Nobody wants to memorize those, so DNS, the Domain Name System, keeps a giant directory mapping names to addresses. When you type a domain name, your computer asks a resolver to look it up. That resolver climbs a chain: it asks a root server which server handles the ending, like .com, then asks that top-level domain server which server handles the specific domain, then asks that authoritative server for the actual IP address. Each answer points to the next place to ask, until the chain bottoms out with a real address.

Climbing that whole chain for every single request would be slow, so resolvers cache the answer. Once a lookup resolves a name, the resolver stores the result for a set amount of time and reuses it on the next request, skipping the hops it already walked. This is why the second visit to a site often feels snappier than the first. If the authoritative server for a domain goes down, any cached answers still work until they expire, but once they expire, lookups for that domain fail until the server comes back or another server takes over.

A domain name is not fused to one machine. It is just a pointer stored in a DNS record, and that record can be changed at any time. If a site moves to a new server with a new IP address, the owner updates the DNS record, and the same name now resolves to the new address. This separation of name from machine is what lets sites change hosting providers, add backup servers, or recover from an outage without forcing every visitor to learn a new name. It connects directly to how the rest of the network survives failures: routing around broken paths, and DNS routing around broken servers, are the same idea at different layers.

Key terms

DNS
The Domain Name System, a distributed directory that maps human-readable domain names to numeric IP addresses.
IP address
The numeric address that identifies a specific machine on a network.
Resolver
The software that performs a DNS lookup by querying servers in sequence until it finds the address.
Authoritative server
The server that holds the official DNS record for a specific domain and gives the final answer in a lookup.
Caching
Storing a previous lookup's result temporarily so later requests can skip repeating the same chain of queries.

Watch it explained

  1. How it worksWalk me through the chain of servers a lookup climbs to resolve one domain name.
  2. How it worksHow does caching a lookup result save the whole chain from being walked all over again?
  3. Going furtherWhat happens when the name server holding a domain's record goes down?
  4. Common mistakeWhy isn't a domain name permanently welded to one particular machine?

Check yourself

Your turn1 of 2
A DNS lookup climbs a chain of 8 servers before resolving a domain name, and caching later saves 2 of those hops on the next lookup. How many hops does the cached lookup need?

End of topic.