Understand DNS resolution from root servers to authoritative servers. Learn to use the dig command to trace DNS lookups, understand NS records, and see how your browser finds IP addresses.

Every time you type google.com in your browser, something magical happens behind the scenes. Your computer has no idea what google.com means – it only understands IP addresses like 142.250.190.78.
So how does it find the right IP? That's the job of DNS – the Domain Name System.
Let's explore how DNS resolution works, and use the dig command to see it in action.
DNS (Domain Name System) is often called the "phonebook of the internet." It translates human-readable domain names into machine-readable IP addresses.
Imagine memorizing 142.250.190.78 instead of google.com.
Now imagine doing that for every website you visit. That's why DNS exists – to let humans use names while computers use numbers.
| You Type | DNS Returns |
|---|---|
| google.com | 142.250.190.78 |
| amazon.com | 52.94.236.248 |
| github.com | 140.82.121.3 |
DNS isn't a single server – it's a distributed, hierarchical system with three main levels:
DNS Hierarchy showing Root, TLD, and Authoritative servers
| Level | Name | Example | Responsibility |
|---|---|---|---|
| 1 | Root Servers | . (dot) | Know where TLD servers are |
| 2 | TLD Servers | .com, .org, .net | Know where domain authorities are |
| 3 | Authoritative Servers | google.com, amazon.com | Know the actual IP addresses |
Think of it like asking for directions:
dig Command?dig (Domain Information Groper) is a DNS diagnostic tool that lets you query DNS servers directly and see the resolution process.
| Use Case | Purpose |
|---|---|
| Debugging DNS issues | "Why can't users reach my site?" |
| Verifying DNS changes | "Did my DNS update propagate?" |
| Understanding DNS flow | "How does resolution actually work?" |
| Security auditing | "What DNS records are exposed?" |
dig [record_type] [domain] [@server]
Linux/Mac: Usually pre-installed. If not: sudo apt install dnsutils or brew install bind
Windows: Install BIND or use WSL
Let's trace DNS resolution step by step using dig, just like a recursive resolver would.
dig commands mapped to DNS lookup stages
Walk the full lookup, one server at a time:
dig . NS – Root Name ServersThe first step is knowing who manages the root of DNS. The root is represented by a single dot (.).
dig . NS
;; ANSWER SECTION:
. 518400 IN NS a.root-servers.net.
. 518400 IN NS b.root-servers.net.
. 518400 IN NS c.root-servers.net.
. 518400 IN NS d.root-servers.net.
. 518400 IN NS e.root-servers.net.
. 518400 IN NS f.root-servers.net.
. 518400 IN NS g.root-servers.net.
. 518400 IN NS h.root-servers.net.
. 518400 IN NS i.root-servers.net.
. 518400 IN NS j.root-servers.net.
. 518400 IN NS k.root-servers.net.
. 518400 IN NS l.root-servers.net.
. 518400 IN NS m.root-servers.net.
| Field | Meaning |
|---|---|
. | The root zone |
518400 | TTL (time-to-live) in seconds – how long to cache |
IN | Internet class |
NS | Name Server record type |
a.root-servers.net. | The actual root server address |
There are 13 root server names (a through m), but each is actually a cluster of hundreds of servers worldwide using anycast for redundancy.
dig com NS – TLD Name ServersNext, we discover who manages the .com TLD (Top-Level Domain).
dig com NS
;; ANSWER SECTION:
com. 172800 IN NS a.gtld-servers.net.
com. 172800 IN NS b.gtld-servers.net.
com. 172800 IN NS c.gtld-servers.net.
com. 172800 IN NS d.gtld-servers.net.
com. 172800 IN NS e.gtld-servers.net.
com. 172800 IN NS f.gtld-servers.net.
com. 172800 IN NS g.gtld-servers.net.
com. 172800 IN NS h.gtld-servers.net.
com. 172800 IN NS i.gtld-servers.net.
com. 172800 IN NS j.gtld-servers.net.
com. 172800 IN NS k.gtld-servers.net.
com. 172800 IN NS l.gtld-servers.net.
com. 172800 IN NS m.gtld-servers.net.
These are the gTLD (generic TLD) servers managed by Verisign. They know about every .com domain registered in the world.
When you ask a root server "Where's google.com?", it says:
"I don't know about google.com, but here are the .com servers – ask them."
dig google.com NS – Authoritative Name ServersNow we find out who actually controls the google.com domain – Google's own name servers.
dig google.com NS
;; ANSWER SECTION:
google.com. 86400 IN NS ns1.google.com.
google.com. 86400 IN NS ns2.google.com.
google.com. 86400 IN NS ns3.google.com.
google.com. 86400 IN NS ns4.google.com.
These are Google's authoritative name servers. They are the final authority for all DNS records under google.com.
| Server | Purpose |
|---|---|
ns1.google.com | Primary name server |
ns2.google.com | Secondary (redundancy) |
ns3.google.com | Tertiary (redundancy) |
ns4.google.com | Quaternary (redundancy) |
Redundancy! If one server goes down, others can still answer queries. Most domains have at least 2 name servers.
dig google.com – The Final AnswerNow we ask Google's authoritative servers for the actual IP address.
dig google.com
;; QUESTION SECTION:
;google.com. IN A
;; ANSWER SECTION:
google.com. 300 IN A 142.250.190.78
| Field | Meaning |
|---|---|
google.com. | The domain we queried |
300 | TTL – cache for 5 minutes |
IN | Internet class |
A | Address record (IPv4) |
142.250.190.78 | The actual IP address! |
This is it! Your browser now knows where to send HTTP requests.
Let's see the complete flow when you type google.com:
Complete DNS resolution flow for google.com
1. Browser: "What's the IP for google.com?"
└─→ Sends query to Recursive Resolver (e.g., 8.8.8.8)
2. Resolver: "Let me check my cache... not found. Ask root servers."
└─→ Query: "Where's .com?"
3. Root Server: "Here are the .com TLD servers"
└─→ Returns: a.gtld-servers.net, b.gtld-servers.net, etc.
4. Resolver: "Ask .com TLD server"
└─→ Query: "Where's google.com?"
5. TLD Server: "Here are Google's authoritative servers"
└─→ Returns: ns1.google.com, ns2.google.com, etc.
6. Resolver: "Ask Google's name server"
└─→ Query: "What's the IP for google.com?"
7. Authoritative Server: "Here's the IP!"
└─→ Returns: 142.250.190.78
8. Resolver: "Caches the answer and returns to browser"
└─→ Browser connects to 142.250.190.78
The recursive resolver does all the heavy lifting. Your computer doesn't query root servers directly – it asks its configured resolver.
Recursive resolver interaction with all DNS server levels
| Resolver | IP Address | Provider |
|---|---|---|
| Google DNS | 8.8.8.8, 8.8.4.4 | |
| Cloudflare | 1.1.1.1, 1.0.0.1 | Cloudflare |
| OpenDNS | 208.67.222.222 | Cisco |
| Your ISP | Varies | ISP-provided |
DNS caching drastically reduces load on name servers. If the resolver recently looked up google.com, it won't need to do the full resolution again until the TTL expires.
NS (Name Server) records are the backbone of DNS delegation. They tell the world "these servers are authoritative for this domain."
| Record Type | Question Answered |
|---|---|
| NS | "Who is authoritative for this domain?" |
| A | "What is the IPv4 address?" |
| AAAA | "What is the IPv6 address?" |
| CNAME | "What is the canonical name (alias)?" |
| MX | "Where should email go?" |
| TXT | "What arbitrary text info exists?" |
# A record (IPv4)
dig google.com A
# AAAA record (IPv6)
dig google.com AAAA
# MX records (mail servers)
dig google.com MX
# TXT records (SPF, DKIM, etc.)
dig google.com TXT
# All records
dig google.com ANY
When you type https://google.com and press Enter:
1. Browser checks local DNS cache
└─→ Not found
2. Browser asks OS for resolution
└─→ OS checks its cache, hosts file
└─→ Not found, asks configured resolver
3. Resolver does full lookup if needed
└─→ Returns: 142.250.190.78
4. Browser establishes TCP connection
└─→ TCP 3-way handshake to 142.250.190.78:443
5. Browser sends HTTPS request
└─→ TLS handshake, then HTTP GET /
6. Server responds
└─→ Google's webpage loads
Each DNS response includes a TTL (Time To Live). During this time, the cached answer is used without re-querying.
| TTL Value | Caching Duration | Use Case |
|---|---|---|
| 300 (5 min) | Short, frequent updates | Dynamic services |
| 3600 (1 hour) | Moderate | Most websites |
| 86400 (1 day) | Long, stable records | Rarely-changing domains |
# Query with specific resolver
dig google.com @8.8.8.8
# Check propagation across resolvers
dig google.com @1.1.1.1
dig google.com @8.8.8.8
dig google.com @208.67.222.222
# +trace shows each step
dig google.com +trace
# Check MX records for email issues
dig yourdomain.com MX
# Check TXT for SPF/DKIM
dig yourdomain.com TXT
DNS changes can take up to 48 hours to propagate globally due to caching. Always set low TTLs before making changes!
| Option | Purpose |
|---|---|
+short | Show only the answer, no metadata |
+trace | Show full resolution path |
+noall +answer | Show only answer section |
@server | Query specific DNS server |
-x IP | Reverse DNS lookup |
# Just get the IP
dig google.com +short
# Full trace
dig google.com +trace
# Query specific server
dig google.com @8.8.8.8
# Reverse lookup
dig -x 142.250.190.78
| Command | What It Shows |
|---|---|
dig . NS | Root name servers |
dig com NS | .com TLD name servers |
dig google.com NS | Google's authoritative servers |
dig google.com | The actual IP address |
dig google.com +trace | Complete resolution path |
DNS is foundational to how the internet works. Every request – whether from a browser, API, or microservice – starts with DNS resolution.
Understanding DNS helps you:
Next time something isn't connecting, reach for dig first. It might just reveal the answer.
Happy resolving! 🌐
Have questions about DNS? Drop a comment or reach out on Twitter @srtenginamath!

Written by Sharanayya R Tenginamath
Software Engineer at McD BERL with 4+ years building scalable full-stack applications with React.js, Next.js, TypeScript, FastAPI and Python. Available to join from Oct 12, 2026.

Understand how the internet's phonebook works. A simple guide to A, AAAA, CNAME, MX, and TXT records.
5 min read

Learn how network devices work together to connect you to the internet. Understand modems, routers, switches, hubs, firewalls, and load balancers with real-world analogies and diagrams.
11 min read

Learn how TCP ensures reliable data transmission over the internet. Understand the 3-way handshake, sequence numbers, acknowledgments, retransmission, and connection termination with clear diagrams.
10 min read