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:
exampleinapi.bookshop.exampleis the top-level domain (TLD), like.com,.orgor.in. (.exampleitself is reserved for examples like ours.)bookshop.exampleis the domain you rent every year from a registrar.api.bookshop.exampleis 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 AA typical answer line reads api.bookshop.example. 300 IN A 203.0.113.10: the name, a TTL of 300 seconds, and the address.
The shortcut
Read the name right to left, and you have the order of the lookup. Each dot is one step down a tree, and a resolver walks down it the same way.
Check the caches
The browser and operating system check whether they already know the answer from a recent lookup. If so, done.
The trap: you change an A record and some users still reach the old server. Nothing is broken; resolvers are honouring the old TTL. Lower the TTL a day before a planned move so that old answers expire quickly.
Drills
Answer fast — trust the rule.
In api.bookshop.example, which part is the top-level domain?
Which record maps a name straight to an IPv4 address?
You want www.bookshop.example to always go wherever bookshop.example goes. Which record fits?
You changed an A record whose TTL was 3600. An hour later, a few users still reach the old server. Why?
In which order does a resolver with an empty cache ask servers?
Remember
- Names are for people; DNS turns them into addresses.
- Read right to left: that is also the lookup order, root → TLD → authoritative.
- Answers are cached for their TTL; lower it before a move.
