Skip to main content

Command Palette

Search for a command to run...

How DNS Resolution Works (Step-by-Step with dig Command)

Understand Root → TLD → Authoritative DNS lookups and see how your browser finds the real IP behind a domain name.

Updated
4 min readView as Markdown
How DNS Resolution Works 
(Step-by-Step with dig Command)
S

Hi, I’m Shubham 👋 A learner sharing my journey in programming, tech, and self-growth. Learning every day and writing what I learn.

What is DNS and why does name resolution exist?

DNS (Domain Name System) is the internet’s phonebook 📖

Humans like typing simple names such as:

google.com

But computers don’t understand names — they need IP addresses like:

142.250.x.x

So DNS exists to solve one big problem:

Domain name → IP address conversion
This process is called DNS Resolution.


What is the dig command and when is it used?

dig stands for Domain Information Groper.
It’s a command-line tool used to inspect DNS records and understand how resolution works.

You use dig when you want to:

✅ check the IP of a domain
✅ check NS/MX/TXT records
✅ debug DNS issues
✅ verify DNS configuration changes
✅ understand how DNS lookup happens

Example:

dig google.com

DNS Resolution happens in layers (big picture)

DNS works like a hierarchy, layer by layer:

Root Name Servers → (.)
TLD Name Servers → (.com, .org, .in)
Authoritative Name Servers → (the real DNS for a domain)

Easy way to remember:

Root → TLD → Authoritative → Answer


1. dig . NS — Root Name Servers

Command:

dig . NS

What does this mean?

. represents the root zone, the top of the DNS hierarchy.

What will you see?

A list of root name servers, such as:

What do root servers do?

Root servers don’t give you the final IP address.
They basically guide you:

✅ “If you want .com, ask these TLD name servers.”

Think of root as:
📌 the main reception desk of the internet.


2) dig com NS — TLD Name Servers (.com)

Command:

dig com NS

What does this show?

It shows the name servers responsible for the .com TLD.

What do TLD servers do?

They still don’t give the final IP address.
They guide you again:

✅ “For google.com, these are the authoritative name servers.”

Think of TLD servers as:
📌 the post office for .com domains.


3. dig google.com NS — Authoritative Name Servers

Command:

dig google.com NS

What does this show?

This shows the authoritative name servers for google.com.
These servers are responsible for storing the actual DNS records for that domain.

Example output might include:

Why do authoritative name servers matter?

Because they hold the real answers:

✅ A record (IP address)
✅ MX record (email routing)
✅ TXT record (verification/security)
✅ CNAME records, etc.

Think of authoritative servers as:
📌 the official domain owner’s records office.


4. dig google.com — The final DNS answer

Command:

dig google.com

What happens here?

This returns the final record, usually:

A record (IPv4 address)
✅ and sometimes AAAA record (IPv6 address)

Example:

So this is what your browser really needs to connect and load the website.


The full DNS resolution flow (what happens behind the scenes)

When you type google.com in your browser:

Step-by-step:

  1. Your browser asks your OS:
    “What’s the IP address of google.com?”

  2. Your device checks local cache

  3. If not found, it asks a Recursive DNS Resolver
    (like your ISP DNS, Google DNS 8.8.8.8, Cloudflare DNS 1.1.1.1)

  4. The recursive resolver performs the lookup in layers:

    • asks Root servers where .com lives

    • asks TLD servers who controls google.com

    • asks Authoritative servers for the final IP

  5. It returns the IP address back to your device

  6. Your browser connects to that IP and loads the website ✅


What are NS records and why do they matter?

NS records tell the world:

✅ “These are the official DNS servers for this domain.”

If NS records are wrong:

❌ website may not open
❌ email may stop working
❌ domain resolution fails

So NS records are like:
📌 “Who is responsible for this domain?”


The role of Recursive Resolvers (the hidden hero)

Your laptop/phone does NOT usually talk directly to root or TLD servers.

That hard work is done by the recursive resolver, which:

✅ performs lookups on your behalf
✅ caches answers (based on TTL)
✅ makes browsing faster
✅ reduces load on DNS infrastructure

That’s why fast DNS services can make your internet feel faster too.


How dig commands map to DNS resolution stages

dig commandWhat it shows
dig . NSRoot name servers
dig com NS.com TLD name servers
dig google.com NSAuthoritative name servers
dig google.comFinal DNS answer (A/AAAA record)

Connecting this to real browser requests

Every time you open any website, DNS is the first step:

✅ browser needs IP
✅ DNS gives IP
✅ browser connects to server
✅ website loads

No DNS = no website.


Final takeaway (easy mental model)

DNS resolution is a layered lookup system:

Root → TLD → Authoritative → IP address → Website

And dig is your tool to see the steps clearly.