The Phonebook Analogy
Looking up a friend's phone number:
| Step | Action |
|---|---|
| You know | "John Smith" |
| Phonebook gives | "555-1234" |
| You call | 555-1234 |
DNS is the internet's phonebook. You know "google.com", DNS gives you an IP address (like <ip-address>), your browser connects.
What Is DNS?
DNS = Domain Name System
| Function | Example |
|---|---|
| Translates names to IPs | example.com → <ip-address> |
| Human-friendly | mysite.com → (an IP address) |
Without DNS, you'd memorize IP addresses instead of domain names. No thanks!
Why We Need DNS
Humans vs Computers
| Humans Remember | Computers Need |
|---|---|
| Words, names | Numbers (IP addresses) |
| google.com | (an IP address) |
| facebook.com | (an IP address) |
DNS bridges the gap.
IP Addresses Change
Note: IPs for big sites can change frequently; DNS is what makes that seamless.
| Event | With DNS |
|---|---|
| Website moves servers | DNS updated once |
| Users type same domain | Works automatically |
IP changes from <old-ip> to <new-ip> | Most users won't notice |
How DNS Works
The Lookup Process
| Step | What Happens |
|---|---|
| 1 | You type: www.example.com |
| 2 | Browser checks cache → miss |
| 3 | OS checks cache → miss |
| 4 | Ask DNS resolver (usually ISP) |
| 5 | Resolver asks root nameserver |
| 6 | Root says: "Ask .com TLD" |
| 7 | .com TLD says: "Ask example.com's nameserver" |
| 8 | Nameserver returns: <ip-address> |
| 9 | Browser connects to that IP |
Uncached lookups are often tens of milliseconds (can be more). Cached results are usually near-instant.
The DNS Hierarchy
┌─────────┐
│ Root │ (knows about TLDs)
│ . │
└────┬────┘
│
┌──────────────┼──────────────┐
│ │ │
┌────▼────┐ ┌────▼────┐ ┌────▼────┐
│ .com │ │ .org │ │ .net │
│ TLD │ │ TLD │ │ TLD │
└────┬────┘ └─────────┘ └─────────┘
│
┌─────▼──────┐
│example.com │ (authoritative nameserver)
└────────────┘
DNS Record Types
| Record | Purpose | Example |
|---|---|---|
| A | Domain → IPv4 | example.com → <ipv4-address> |
| AAAA | Domain → IPv6 | example.com → <ipv6-address> |
| CNAME | Alias to another domain | www → example.com |
| MX | Mail server location | example.com → mail.example.com |
| TXT | Text data (SPF, verification) | "v=spf1 include:..." |
| NS | Authoritative nameservers | ns1.example.com |
Example DNS Configuration
| Type | Name | Value | Purpose |
|---|---|---|---|
| A | @ | <ip-address> | Root domain |
| A | www | <ip-address> | www subdomain |
| CNAME | blog | medium.com | Blog alias |
| MX | @ | mail.example.com | Email routing |
| TXT | @ | "v=spf1..." | Email auth |
DNS Caching
Why Cache?
| Without Cache | With Cache |
|---|---|
| Full lookup: often tens of ms | Cached: near instant |
| Same request repeated | Use stored answer |
| Network overhead | Local response |
Cache Levels
| Level | Duration | Location |
|---|---|---|
| Browser | Seconds-minutes | Your browser |
| OS | Minutes | Your computer |
| Router | Minutes | Home router |
| ISP resolver | Hours | ISP servers |
Each level checked before full lookup.
TTL (Time To Live)
| TTL | Meaning | Trade-off |
|---|---|---|
| Short (minutes) | Cache briefly | Quick updates, more lookups |
| Medium (hours) | Cache for a while | Balanced |
| Long (day+) | Cache for longer | Fewer lookups, slower updates |
DNS Resolver
Your DNS resolver does the heavy lifting:
| Popular Resolver | IP Address | Features |
|---|---|---|
<resolver-ip> | Popular, widely available | |
| Cloudflare | <resolver-ip> | Often fast, privacy-focused |
| OpenDNS | <resolver-ip> | Security filtering |
Why Change Resolver?
| Reason | Benefit |
|---|---|
| Speed | Some resolvers can be faster for you |
| Privacy | Logging/retention policies vary |
| Security | Block malware domains |
| Censorship | May help in some cases |
Common DNS Problems
DNS Propagation
| Scenario | What Happens |
|---|---|
| Changed DNS records | Takes time to spread globally |
| Old TTL not expired | Different users see different results |
| "Propagation time" | Minutes to a couple of days in some cases |
DNS Not Resolving
| Symptom | Possible Cause |
|---|---|
| "Server not found" | DNS server down |
| Domain expired | Registration lapsed |
| Misconfigured records | Wrong IP or typo |
Solution: Flush DNS cache, try different resolver.
DNS Security
Threats
| Attack | Description |
|---|---|
| DNS Hijacking | Redirects queries to malicious IPs |
| DNS Spoofing | Fake responses for phishing |
| DNS Tunneling | Exfiltrate data via DNS queries |
Protections
| Technology | Purpose |
|---|---|
| DNSSEC | Signs records cryptographically |
| DNS over HTTPS (DoH) | Encrypts DNS queries |
| DNS over TLS (DoT) | Encrypted DNS transport |
FAQ
Q: How long does DNS lookup take?
Uncached: often tens of milliseconds (can be more). Cached: usually near-instant.
Q: Why does my site show old content after DNS change?
DNS propagation. Old cached records haven't expired. Wait or flush caches.
Q: Is a public DNS resolver better than my ISP's DNS?
It depends on your network and location. You can try a few public resolvers and see what performs well for you.
Q: Can DNS be used for censorship?
Yes. Networks can block or tamper with DNS. VPNs and encrypted DNS (DoH/DoT) can help in some cases, but they don't bypass every kind of blocking.
Summary
DNS translates human-friendly domain names into IP addresses that computers use to connect.
Key Takeaways:
- DNS is the internet's phonebook
- Hierarchical system: root → TLD → domain
- Common records: A, AAAA, CNAME, MX, TXT
- Caching speeds up repeated lookups
- TTL controls cache duration
- DNSSEC and DoH add security/privacy
- Many popular public resolvers exist
Without DNS, we'd be memorizing IP addresses!
Leave a Comment
Comments (0)
Be the first to comment on this concept.
Comments are approved automatically.