Article
DNS, turning names into addresses
You type www.example.com into your browser. But packets are sent to IP addresses, which are numbers like 203.0.113.7. Nobody wants to remember numbers for every website. So who changes the name into the number? A system called DNS does this, thousands of times a day, without you noticing.
Names for people, numbers for computers
A domain name is a name for a place on the Internet, such as example.com. A DNS (Domain Name System) is the Internet's lookup service. It matches a domain name with the IP address of the computer that has the website.
It works like the contacts list on your phone. You tap "Grandma", not a long phone number. Your phone looks up the number for you. DNS does the same for the Internet.
Read a domain name from right to left. It goes from the biggest group to the smallest:
www . example . com
| | |
| | +-- top-level domain (.com, .org, .edu ...)
| +---------- the name of the site or company
+------------------ a computer or service at that siteDNS is not one computer. It is a very large number of DNS servers around the world, organised in levels. No single server knows every name. This is how the system stays fast and keeps working even if some servers fail.
Check your understanding
What does DNS give to a browser?
How a lookup works
Your browser does not ask the whole world. It starts with a nearby server called a DNS resolver, which is usually run by your Internet provider. Here is what happens when the resolver does not know the answer yet:
Looking up www.example.com
- 1
Browser → Resolver
What is the IP address of
www.example.com? - 2
Resolver → Root server
Who knows about
.comnames? - 3
Root server → Resolver
Ask the
.comservers. - 4
Resolver → .com server
Who knows about
example.com? - 5
.com server → Resolver
Ask example.com's own name server.
- 6
Resolver → example.com server
What is
www.example.com? - 7
example.com server → Resolver
203.0.113.7 - 8
Resolver → Browser
203.0.113.7
Only now can the browser send its request to 203.0.113.7. DNS does not carry the web page. It only finds the address.
A resolver also remembers answers for a while. This is called caching. If you, or anyone using the same resolver, ask for the same name soon after, the answer comes straight back. Lookups are small messages, so they are quick.
Check your understanding
A DNS resolver remembers answers for a while. What is the benefit?
Worked example
Kofi types mail.example.com for the first time today. The table shows who talks to whom.
| Step | Who asks | Who answers | What is said |
|---|---|---|---|
| 1 | Browser | Resolver | "What is the IP of mail.example.com?" |
| 2 | Resolver | Root server | Points to the .com servers |
| 3 | Resolver | .com server | Points to example.com's name server |
| 4 | Resolver | example.com's server | "mail.example.com is 203.0.113.25" |
| 5 | Resolver | Browser | "203.0.113.25" (and it caches the answer) |
When Kofi's friend, who uses the same resolver, asks for mail.example.com five minutes later, the resolver already has the answer. Steps 2 to 4 are skipped.
Two more facts follow from this. First, if a website moves to a new server, its owner updates the DNS record. The name stays the same for users, and only the number changes. Second, if DNS stops working, you can still reach a site by typing its IP address, but nobody wants to remember the numbers.
Common mistakes
- "DNS sends me the web page." No. DNS only returns an IP address. The page comes from the web server.
- "A domain name is an IP address." The domain name is the human-friendly label. The IP address is what the packets use.
- "One DNS server holds all names." DNS is spread over many servers in levels.
- "DNS and HTTP are the same." DNS finds the address. HTTP, in the next article, asks for the page.
On the exam
Know the one-sentence job of DNS: it translates a domain name into an IP address. If a question says a site works by IP address but not by name, DNS is the likely problem.
Key words
Domain name: a human-friendly name for a place on the Internet, such as example.com.
DNS (Domain Name System): the system that matches domain names with IP addresses.
DNS resolver: a server that looks up names for your device.
Caching: remembering an answer for a while to answer faster next time.