DNS — How Names Become Addresses
The internet's phone book, and why 'it's always DNS' is a running joke in operations.
You type github.com, not 140.82.121.3. DNS (the Domain Name System) is the service that translates names people remember into IP addresses machines use. When it misbehaves, half the internet looks broken — hence the DevOps meme, “It’s always DNS.”
🎯 Learning Objectives
By the end of this lesson you will:
- Understand what DNS does and why it exists
- Follow a DNS lookup from start to finish
- Know the common DNS record types
- Understand TTL and DNS caching
Why DNS Exists
IP addresses change, and nobody wants to memorise numbers. DNS gives us a stable, human-friendly name that points to whatever IP is current. Change servers? Update the DNS record — the name stays the same.
💡 The one-line version
DNS is the internet’s phone book: you look up a name and get back an address.
How a Lookup Works
When you request www.example.com, your computer asks a chain of servers until it gets an answer:
You → Resolver → Root server → .com server → example.com server → IP!- Resolver (usually your ISP or a public one like 8.8.8.8) receives the query.
- It asks a root server: “who handles
.com?” - The .com server replies: “ask example.com’s nameserver.”
- The authoritative nameserver returns the actual IP.
- The resolver caches the answer and hands it back to you.
All of this usually happens in a few milliseconds.
Common Record Types
| Record | Purpose | Example |
|---|---|---|
| A | Name → IPv4 address | example.com → 93.184.216.34 |
| AAAA | Name → IPv6 address | example.com → 2606:2800:... |
| CNAME | Alias one name to another | www → example.com |
| MX | Where email is delivered | mail.example.com |
| TXT | Free-form text (SPF, verification) | "v=spf1 ..." |
| NS | Which nameservers are authoritative | ns1.example.com |
⚠ CNAME gotcha
A CNAME can’t sit at the root of a domain (example.com itself) alongside other records. That’s a classic real-world mistake — use an A record or your provider’s “ALIAS/ANAME” instead.
TTL and Caching
Every DNS record carries a TTL (Time To Live) — how many seconds resolvers may cache the answer before asking again.
- High TTL (e.g. 86400 = 1 day): fewer lookups, but changes take longer to spread.
- Low TTL (e.g. 60): changes propagate fast, at the cost of more queries.
💡 Planning a migration
Before moving a service to a new IP, lower the TTL a day in advance. Then when you switch, the change propagates in minutes instead of hours.
See It Yourself
Use dig to inspect DNS directly:
dig github.com # full lookup
dig github.com +short # just the answer
dig MX gmail.com +short # mail servers🧪 Hands-on Lab
Investigate a Domain's DNS
- Find the A record (IPv4) for a website you use
- Look up its MX records to see where its email goes
- Check the TTL on the A record
🧠 Knowledge Check
What does an A record do?
You need a DNS change to take effect quickly during a migration. What should you do beforehand?
💼 Interview Preparation
Why do people joke that 'it's always DNS'?
Summary
You now understand how DNS resolves names to addresses, the key record types (A, AAAA, CNAME, MX, TXT, NS), and how TTL controls caching and propagation. Next, we’ll look at HTTP — the protocol your apps actually speak — and how load balancers spread traffic across servers.