DNS
Definition
DNS
- In plain English
- DNS is the internet's directory that turns human-friendly names into IP addresses.
- Think of it like
- It is like your phone's contacts list, where you tap a name and the phone dials the number.
Domain name
- In plain English
- A domain name is the human-readable name of a site, such as tickets.example.com.
- Think of it like
- It is like a shop's name on its sign rather than its map coordinates.
Why it exists
You move your service to a new machine, and its IP address changes. Requiring every user to remember the new number would break access. A stable name lets you update the destination in one directory.
Saving lookup answers nearby reduces repeated work. Old saved answers delay address changes.
How it works
Resolver
- In plain English
- A resolver is the server that does the lookup work on your device’s behalf.
- Think of it like
- It is like a librarian who finds the book so you do not search every shelf.
TTL
- In plain English
- A TTL is how many seconds a DNS answer may be reused before it must be looked up again.
- Think of it like
- It is like the best-before date on a carton of milk.
- Check nearby copies
The browser and operating system check saved answers first.
- Ask the recursive resolver
The resolver returns a saved answer or looks up a fresh one.
- Follow referrals
The root directs the resolver to .com servers. They direct it to servers holding the domain's records.
- Save and connect
The resolver saves the address for its TTL and returns it. The client then connects.
The browser asks the resolver for tickets.example.com. The resolver follows root and .com referrals to the authoritative server, then returns 203.0.113.7 with TTL 300.
| Record | Points to |
|---|---|
| A | An IPv4 address |
| AAAA | An IPv6 address |
| CNAME | Another hostname |
| MX | Mail server hostname and priority |
| TXT | Text used for verification or mail policy |
Examples
Move a podcast host
Your podcast host is moving its audio service to a new machine.
- Prepare a day ahead
Lower TTL from 86,400 seconds to 60; allow the old TTL to expire before moving.
- Switch
Change the A record while keeping the old host working during the overlap.
- Settle
After verifying the move, raise the TTL again.
; Before preparation
audio.example.com. 86400 IN A 203.0.113.7
; During migration, after the old TTL has elapsed
audio.example.com. 60 IN A 203.0.113.8
; After verification
audio.example.com. 86400 IN A 203.0.113.8The insight
Plan TTL before a change, not during it.
Route regional wildfire alerts
Your wildfire alerts site runs in west and east regions.
GeoDNS
- In plain English
- GeoDNS gives different DNS answers depending on the estimated location of the requester.
- Think of it like
- It is like a national helpline that connects you to your nearest branch.
Choose a DNS service that checks whether each region is working. If west fails, stop returning west in new lookups. Old saved answers still delay the switch.
West and east users ask DNS for an address. DNS points to the regional servers; a west failure removes west from new answers.
The insight
DNS directs new connections toward a region.
Move a coffee service by name
Your coffee app must keep working when you switch to a provider that accepts the same requests.
Store api.brew.example instead of an IP. Use CNAME to point order.brew.example at a provider's hostname. The new provider must accept your app's requests and serve your custom hostname.
DNS changes where the app connects. Set up the new provider before switching the name.
The insight
Names let you move services without updating every installed app.
Trade-offs
Pros
- Long TTLs reduce lookups.
- Saved answers reduce startup delay.
- Valid cached answers can outlast brief DNS outages.
Cons
- Address changes reach callers slowly.
- Failover waits for old answers to expire.
Use when
- Addresses rarely change.
- Lookup cost matters more than rapid redirection.
Avoid when
- A migration is approaching.
- Fast DNS-based failover is required.
Quick check
Takeaways
- DNS maps names to IPs.
- Answers are cached for their TTL.
- Names let you move servers without telling users.