DNS: The Internetβs Phone Book π
Who needs this? DevOps engineers, cloud engineers, developers, and literally anyone whoβs ever wondered βhow does typing google.com actually work?β
The βWait, What?β Moment
Picture this: You type google.com in your browser and boom - Google appears.
You: βCool, it just works!β Your computer: frantically running around asking 15 different servers where Google lives
βHow does my computer find google.com?β βThatβs the neat part - DNS does it for you!β
Let me blow your mind: Your computer has no idea what βgoogle.comβ means. Computers speak in numbers - IP addresses like 142.250.190.46. DNS is the translator between human language (google.com) and computer language (142.250.190.46).
What Even is DNS?
DNS = Domain Name System
Think of it as the internetβs massive phone book, but instead of:
John Doe β 555-0123
Itβs:
google.com β 142.250.190.46
The process:
- You type
google.com - Your computer: βWhatβs the IP for google.com?β
- DNS: βThatβs 142.250.190.46β
- Your computer: βThanks!β (connects to Google)
- You: (sees cat videos)
Simple, right? But wait till you see the chaos behind the scenesβ¦
Why Do We Even Need This?
Pop Quiz Time! π§
Which would you rather remember?
Option A:
- google.com
- youtube.com
- netflix.com
- amazon.com
Option B:
- 142.250.190.46
- 172.217.16.238
- 54.175.223.129
- 176.32.103.205
Yeah, exactly. Option A, every single time.
The Real-World Analogy
Imagine I invite you over and say: βI live in Sweet Home Apartments!β
You: βCool! How do I get there?β Me: gives vague directions You: gets lost for 2 hours
Now imagine I say: βI live at 12-0-29/B, Paradise Street, Silicon Valley, 500032β
You: punches it into Google Maps You: arrives in 15 minutes
The apartment name = Domain name (google.com) The actual address = IP address (142.250.190.46)
DNS is your GPS for the internet. Without it, youβd be lost.
expand your knowledge bro!
DOMAIN EXPANSION
But Wait, Thereβs More Problems!
βBillions of internet usersβ βOne DNS serverβ Corporate needs you to find the differences
Problem #1: Do We Ask DNS Every Single Time?
Imagine calling 411 (directory service) before EVERY phone call:
You: "What's Mom's number?"
411: "555-0123"
You: *calls mom*
---
5 minutes later
You: "What's Mom's number?"
411: "Dude, I just told you... 555-0123"
You: *calls mom again*
This is insane, right? That poor DNS server would have a mental breakdown.
Solution: DNS Caching π§ πΎ
Your computer is smart. It remembers stuff:
- Browser Cache - βI looked this up 5 seconds ago, I remember!β
- OS Cache - βYeah, Iβve got google.comβs IP in my notesβ
- Router Cache - βEveryone in this house Googles stuff, lemme cache itβ
- ISP Cache - βMillions ask for google.com daily, Iβll remember itβ
See Caching in Action
Try this:
- Open DevTools (Press F12)
- Go to Network tab
- Visit a NEW website
- Look at βTimingβ β Youβll see DNS Lookup: 50ms
- Refresh the page
- Look again β DNS Lookup: 0ms β¨
βDNS Cachingβ βοΈ SPEED
Problem #2: Single Point of Failure
What if THE DNS server crashes?
βThe DNS server is downβ βThis is fineβ Narrator: It was not fine. The entire internet was down.
Solution: Decentralization!
Instead of one boss server, we have a whole hierarchy. Welcome toβ¦
The DNS Hierarchy: A Corporate Structure
Small brain: One DNS server Medium brain: Multiple DNS servers Large brain: Hierarchical DNS system Galaxy brain: 13 root servers controlling billions of requests using anycast
The Root Name Servers: The OGs
There are 13 root name servers labeled A through M. These are the CEOs of the internet.
βWait, 13 servers for 8 BILLION people?!β
Plot twist: Each βserverβ is actually hundreds of physical servers using the same IP address (anycast magic). You connect to whichever is closest.
Check them out: IANA Root Servers
These 13 IPs are hardcoded into every device. Theyβre like the internetβs founding fathers.
Anatomy of a Domain Name
Letβs dissect: www.iith.dev
βββββββββββββββββββββββββββββββββββ
β www . iith . dev β
β β β β β
β subdomain apex TLD β
βββββββββββββββββββββββββββββββββββ
- www - The apartment number (subdomain)
- iith - The building name (apex/second-level domain)
- .dev - The city (top-level domain)
Common TLDs: .com, .org, .dev, .io, .ai, .wtf, .ninja (yes, really)
The DNS Quest: A Journey of 1000ms
When you type iith.dev, your request goes on an ADVENTURE:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β YOUR COMPUTER β
β "I need iith.dev!" β
ββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β ROOT NAME SERVER (.) β
β "idk about iith.dev, but I know where β
β ALL .dev domains live. Ask them β" β
ββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β TLD NAME SERVER (.dev) β
β "iith.dev? Yeah, I know that guy! β
β His authoritative server is over there β" β
ββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β AUTHORITATIVE NAME SERVER β
β "iith.dev? That's 76.76.21.21!" β
ββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β YOUR COMPUTER β
β "Found it! Connecting to 76.76.21.21..." β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
All of this happens in milliseconds. Your computer is basically The Flash.
Try it yourself:
nslookup google.com
Output:
Server: 1.1.1.1
Address: 1.1.1.1#53
Non-authoritative answer:
Name: google.com
Address: 142.250.190.46
βI looked up a domainβ βThatβs the fastest lookup in the Westβ
DNS Records: The Different Flavors
When you own a domain (via Cloudflare, Route53, etc.), you work with different record types. Each one does something different.
Drake rejecting: Memorizing IP addresses Drake approving: DNS Records doing it for me
A Record - The OG Address Record
What it does: Maps domain β IPv4 address
Type: A
Name: @ (@ = your apex domain)
Value: 192.168.1.100
TTL: 3600 (Cache for 1 hour)
Real example:
iith.dev β 192.168.1.100
Test it:
nslookup iith.dev
AAAA Record - Aβs Bigger Brother
What it does: Maps domain β IPv6 address
Type: AAAA
Name: @
Value: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
TTL: 3600
Why IPv6? We ran out of IPv4 addresses. There are only ~4.3 billion possible IPv4 addresses, but 340 undecillion (yes, thatβs a real number) IPv6 addresses.
βHow many IPv6 addresses are there?β βYes.β
CNAME Record - The Alias Master
What it does: Points one domain to ANOTHER domain (not an IP!)
Type: CNAME
Name: blog
Value: iith.dev
TTL: 3600
Now blog.iith.dev β iith.dev β whatever IP iith.dev has
Itβs like saying βask my brother, he knowsβ π
CNAME: The βLet Me Sleepβ Record
Scenario: You deploy your app on Vercel
Method 1: The Disaster
Type: A
Name: app
Value: 76.76.21.21
3am: Vercel migrates your server to new hardware (new IP: 76.76.21.98)
Your website is down Youβre getting angry calls You canβt sleep anymore
Method 2: The Galaxy Brain Move
Type: CNAME
Name: app
Value: cname.vercel-dns.com
3am: Vercel migrates servers, updates THEIR A record
You: sleeping peacefully π΄
Your CNAME: still works perfectly
βModern problems require modern solutionsβ βCNAME recordsβ
Try it:
nslookup app.vercel.app
# You'll see it CNAMEs to something else
MX Record - The Mail Guy
What it does: Tells the world where to send emails for your domain
Type: MX
Name: @
Value: mail.google.com
Priority: 10
TTL: 3600
When someone emails [email protected], their email server checks your MX record: βOh, deliver to Googleβs mail servers!β
Multiple MX records = Backup mail servers:
Priority 10: mail1.google.com (try this first)
Priority 20: mail2.google.com (if first one is down)
Lower number = higher priority (yeah, itβs backwards, I know)
Check MX records:
nslookup -type=MX gmail.com
TXT Record - The βNotesβ Field
What it does: Stores text data (usually for machines, not humans)
Real uses:
- π Domain verification - βProve you own this domainβ
- π§ SPF records - βThese servers can send email on my behalfβ
- β DKIM - Email authentication
- π API keys - Some services use this
Type: TXT
Name: @
Value: "v=spf1 include:_spf.google.com ~all"
TTL: 3600
TXT records be like: βv=spf1 ip4:192.0.2.0/24 include:_spf.example.com ~allβ βWhat does it mean?β βNo one knows, but itβs provocativeβ
Check TXT records:
nslookup -type=TXT google.com
NS Record - The Power Move
What it does: Delegates a subdomain to different name servers
Type: NS
Name: api
Value: ns1.example.com
TTL: 3600
Now ALL queries for *.api.iith.dev go to ns1.example.com (which runs its own DNS server).
Use case: Your company is huge. Each team manages their own subdomain independently:
api.company.comβ Team Aβs DNSblog.company.comβ Team Bβs DNSshop.company.comβ Team Cβs DNS
βYou get your own DNS server! And YOU get your own DNS server! EVERYBODY gets their own DNS server!β
Hands-On Lab: DNS Commands Thatβll Make You Look Cool
typing βnslookup google.comβ in terminal βIβm in.β
Command 1: Basic Lookup
nslookup google.com
What youβll see:
Server: 1.1.1.1
Address: 1.1.1.1#53
Non-authoritative answer:
Name: google.com
Address: 142.250.190.46
Translation:
- βI asked 1.1.1.1 (Cloudflare)β
- βThey said google.com is 142.250.190.46β
- βNon-authoritative = this is cached, not from Googleβs official DNSβ
Command 2: Choose Your DNS Fighter
# Ask Cloudflare
nslookup google.com 1.1.1.1
# Ask Google
nslookup google.com 8.8.8.8
# Ask Quad9
nslookup google.com 9.9.9.9
Different DNS servers might give different answers (caching, anyone?)
Command 3: Get Specific
# MX records (mail servers)
nslookup -type=MX google.com
# NS records (name servers)
nslookup -type=NS google.com
# TXT records (all the juicy metadata)
nslookup -type=TXT google.com
# AAAA records (IPv6)
nslookup -type=AAAA google.com
Command 4: The Nuclear Option - dig
dig google.com
This gives you EVERYTHING. Like, everything everything.
The cool part:
dig google.com +trace
This shows you the ENTIRE journey - from root servers to the final answer. Itβs like watching your query go on a quest.
Sample output:
. 518400 IN NS a.root-servers.net.
; ... (asking root servers)
com. 172800 IN NS a.gtld-servers.net.
; ... (asking .com TLD servers)
google.com. 300 IN A 142.250.190.46
; Found it!
βdig +traceβ βShows the entire DNS journeyβ βItβs beautifulβ
Command 5: Reverse Lookup
nslookup 8.8.8.8
Output:
Server: 1.1.1.1
Address: 1.1.1.1#53
8.8.8.8.in-addr.arpa name = dns.google.
βWhat domain does this IP belong to?β Spoiler: Itβs Googleβs DNS server!
DNS Troubleshooting: When Stuff Breaks
βDNS is downβ βThis is a CODE REDβ βEVERYTHING IS ON FIREβ
The Local DNS Files
1. The Hosts File - The Nuclear Override
cat /etc/hosts
What youβll see:
127.0.0.1 localhost
::1 localhost
Pro secret: Add custom entries here to test stuff locally!
192.168.1.100 myapp.local
Now typing myapp.local in your browser goes to 192.168.1.100 - NO DNS LOOKUP NEEDED.
Use cases:
- Testing websites before DNS propagates
- Blocking websites (map facebook.com to 127.0.0.1)
- Local development
βEdit /etc/hosts to test locallyβ βNo need to wait for DNS propagationβ βItβs free real estateβ
2. Resolver Config
cat /etc/resolv.conf
What youβll see:
nameserver 1.1.1.1
nameserver 8.8.8.8
This tells your system: βUse these DNS servers for lookupsβ
Popular Public DNS Servers
| Provider | Primary | Secondary | Vibe |
|---|---|---|---|
| Cloudflare | 1.1.1.1 | 1.0.0.1 | Fastest, privacy-focused π |
| 8.8.8.8 | 8.8.4.4 | Reliable, basically everywhere π | |
| Quad9 | 9.9.9.9 | 149.112.112.112 | Blocks malicious sites π‘οΈ |
Switch DNS servers:
nslookup google.com 1.1.1.1
Clear DNS Cache (When Things Get Weird)
macOS:
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
Windows:
ipconfig /flushdns
Linux:
sudo systemd-resolve --flush-caches
# or
sudo /etc/init.d/nscd restart
βDNS not working?β βHave you tried flushing the cache?β
Common DNS Disasters and How to Fix Them
π¨ βDNS_PROBE_FINISHED_NXDOMAINβ
Translation: βBruh, this domain doesnβt existβ
Possible causes:
- You typoβd the domain (gogle.com instead of google.com)
- The domain actually doesnβt exist
- Your DNS is drunk (cached wrong info)
Fixes:
# Check if you can reach it with a different DNS
nslookup example.com 8.8.8.8
# Flush your DNS cache
# (see commands above)
# Try in incognito mode (fresh DNS cache)
π¨ Website Down but IP Works
Test:
# Get the IP
nslookup example.com
# Try accessing via IP
curl http://142.250.190.46
If IP works but domain doesnβt β DNS problem!
Fix:
- Flush DNS cache
- Change DNS servers (1.1.1.1 or 8.8.8.8)
- Wait (DNS propagation can take 24-48 hours)
βDNS propagation takes 24-48 hoursβ βWhy canβt it be instant?β βBecause the internet is held together by duct tape and prayersβ
π¨ Slow DNS Resolution
Diagnose:
dig google.com
# Look at bottom for "Query time: 234 msec"
If > 100ms, thatβs slow!
Fixes:
# Try different DNS servers
nslookup google.com 1.1.1.1 # Usually fastest
# Check if your ISP's DNS is potato quality
nslookup google.com # Uses your default DNS
nslookup google.com 8.8.8.8 # Compare timing
Pro Tips From the Trenches
βDNS pro tipsβ βTake my wisdom, young padawanβ
1. Lower TTL Before Making Changes
The smart workflow:
Day -1: Lower TTL to 300 (5 minutes)
Day 0: Make your DNS change
Day 1: Wait for old cache to expire
Day 2: Raise TTL back to 3600 (1 hour)
Why? If you screw up, only 5 minutes of caching instead of 24 hours!
2. Always Have Backup Name Servers
Bad:
NS: ns1.example.com
Good:
NS: ns1.example.com
NS: ns2.example.com
NS: ns3.example.com
If one dies, the others keep working!
3. Test Before Propagation
# Your DNS change hasn't propagated yet
# Test it anyway:
nslookup yoursite.com @ns1.yourprovider.com
# Or directly query the authoritative server
dig yoursite.com @ns1.yourprovider.com
4. Use dig +trace for Deep Debugging
dig +trace yoursite.com
This shows you EVERY step of the resolution. When something breaks, this tells you WHERE it broke.
5. Monitor DNS Propagation
Visit: https://www.whatsmydns.net
Enter your domain and see if your DNS change has propagated worldwide!
Different locations might see different IPs (during propagation).
The Ultimate DNS Cheat Sheet
# Basic lookup
nslookup google.com
# Lookup using specific DNS server
nslookup google.com 1.1.1.1
# Get specific record types
nslookup -type=MX google.com
nslookup -type=NS google.com
nslookup -type=TXT google.com
# Detailed info (power user move)
dig google.com
# Show entire resolution path
dig google.com +trace
# Reverse lookup (IP β domain)
nslookup 8.8.8.8
# Flush DNS cache
# macOS: sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder
# Windows: ipconfig /flushdns
# Linux: sudo systemd-resolve --flush-caches
# Check local DNS settings
cat /etc/hosts # Local overrides
cat /etc/resolv.conf # DNS server config
# Test DNS speed
dig google.com | grep "Query time"
βDNS commandsβ βI know kung fuβ
Wrapping This Up
So, what did we learn?
β DNS translates domain names β IP addresses β Itβs hierarchical (Root β TLD β Authoritative) β Caching makes it fast (browser β OS β router β ISP) β Different record types do different things β CNAME records let you sleep at night β When in doubt, flush the cache
DNS is basically:
- A distributed database
- That never goes down (thanks to redundancy)
- That caches aggressively
- That makes the internet usable for humans
Without DNS, youβd have to memorize IP addresses like a maniac. Thank you, DNS. Youβre the real MVP.
βDNS doing all this work invisiblyβ βNot all heroes wear capesβ
Your Next Steps
- Try every command in this guide - Seriously, open your terminal right now
- Buy a domain ($12/year) and mess with DNS records
- Break things - Best way to learn (use a test domain!)
- Learn DNS security - DNSSEC, DoH, DoT
- Host your own DNS server (advanced, but cool!)
One More Thingβ¦
βItβs not DNSβ βThereβs no way itβs DNSβ βIt was DNSβ
Itβs always DNS. 99% of internet problems? DNS. Website down? DNS. Email not working? DNS. Canβt connect to server? Believe it or not, also DNS.
I am not commeting anything on it, please talk to my laweyer.
Had Fun Reading the blog
Follow me on GitHub π
Now go forth and resolve those domains! π―
