4. DNS
1
The picture to keep in your head2
4.1 Why do we need names at all?3
4.2 What are the parts of a domain name?4
4.3 What happens, step by step, when a name is looked up?5
4.4 What kinds of DNS records are there?6
4.5 What is a TTL, and why does DNS cache so much?7
4.6 How can DNS spread users across servers or send them to the nearest one?8
4.7 Why do DNS changes "take time to propagate"?9
4.8 What happens when DNS fails?10
Memory card and where the analogy breaks11
Practice: five levels12
Interview questions13
Solutions14
Sources15
Code lab4. DNS
Memory card and where the analogy breaks
3 min read+10 XP
The memory card (tear this page out)
| # | Question | Memory code |
|---|---|---|
| 4.1 | Why names? | Names for people, numbers for machines |
| 4.2 | Parts of a domain? | Right to left, big to small |
| 4.3 | The lookup chain? | Nobody knows everything; everyone knows who to ask next |
| 4.4 | Record types? | A for Address (quad-A for the four-times-longer IPv6), CNAME for 'call them instead', MX for Mail, TXT for proofs, NS for who's in charge. |
| 4.5 | TTL and caching? | TTL is the use-by date on a saved answer |
| 4.6 | DNS load balancing, GeoDNS? | DNS picks the city; the load balancer picks the counter |
| 4.7 | Propagation? | DNS doesn't spread, old copies expire. Lower the TTL before you move house. |
| 4.8 | DNS failures? | If DNS is down, you're down, even when everything is up |
The whole chapter in one line: Ask the friend who knows who to ask, save the answer until its use-by date, and lower that date before you move.
Where the analogy breaks
- Your phone's contacts are yours alone. A resolver's cache is shared by thousands of users, which is why one cached answer saves so many queries, and why one stale answer affects so many people.
- Phone numbers belong to one phone. One domain name can point to many servers, and even give different answers to different people (4.6).
- Your friend gives up if a directory is closed. DNS has many copies of every level, spread worldwide, so losing one server usually goes unnoticed. Losing a whole provider doesn't.
Quick check
Five questions on this chapter. Pick an answer, then check it.
quiz