Skip to main content

Command Palette

Search for a command to run...

How DNS Resolution Works

Published
•4 min read•View as Markdown

If you have ever typed google.com in your browser and the page opened, DNS was working silently in the background.

Most people use the internet every day, but very few know how a website name turns into a server IP address.
That is exactly what DNS resolution does.

In this article, we will understand DNS resolution step by step using the dig command.

DNS: The Internet’s Phonebook

Computers do not understand website names like google.com.

They understand IP addresses, like 142.250.190.14.

DNS (Domain Name System) is like a phonebook:

  • You give a name → google.com

  • DNS finds the number → IP address

  • Your browser connects to that IP

Without DNS, we would have to remember IP addresses for every website. That would be painful.

Why Name Resolution Exists

Name resolution exists because:

  • Names are easy for humans to remember

  • IP addresses are easy for machines to use

  • DNS connects humans and machines

So DNS acts as a translator between names and IPs.

What is the dig Command?

dig stands for Domain Information Groper.

It is a command-line tool used to:

  • Check DNS records

  • Debug DNS problems

  • Understand how DNS resolution works

Developers and system engineers use dig to see what is happening behind the scenes.

Example:

dig google.com

This command shows how DNS finds the IP for google.com.

DNS Resolution Happens in Layers

DNS resolution does not happen in one step.

It happens in layers:

Root servers
   ↓
TLD servers (.com, .org, .in)
   ↓
Authoritative name servers

Let’s walk through each layer using dig.

Understanding dig . NS (Root Name Servers)

Command:

dig . NS

What this means:

  • . represents the root of DNS

  • NS means Name Servers

This command shows the root name servers of the internet.

Why Root Servers Matter

  • Root servers do not know IPs of websites

  • They only know where TLD servers are

  • They are the first stop in DNS resolution

Think of root servers as:

“I don’t know google.com, but I know who manages .com.”


Understanding dig com NS (TLD Name Servers)

Command:

dig com NS

This asks:

“Who is responsible for .com domains?”

The answer is TLD name servers.

What TLD Servers Do

  • They manage domains under .com

  • They do not know IP addresses

  • They know which authoritative server owns a domain

Example:

“google.com is managed by these name servers.”


Understanding dig google.com NS (Authoritative Name Servers)

Command:

dig google.com NS

This shows the authoritative name servers for google.com.

Why Authoritative Servers Are Important

  • These servers have the final truth

  • They store DNS records like:

    • A record

    • AAAA record

    • MX record

If you want the real IP of google.com, this is where it comes from.


Understanding dig google.com (Full DNS Resolution)

Command:

dig google.com

This is what usually happens when your browser makes a request.

Behind the scenes:

  1. Browser asks the recursive resolver

  2. Resolver checks cache

  3. If not found:

    • Ask root server

    • Ask TLD server

    • Ask authoritative server

  4. Get IP address

  5. Return IP to browser

  6. Browser connects to the server

All this happens in milliseconds.


How Recursive Resolvers Work

You usually don’t talk to root servers directly.

Your system talks to a recursive resolver (ISP or public DNS).

The resolver:

  • Does the full DNS lookup

  • Caches the result

  • Saves time for future requests

That’s why websites often load faster the second time.


Connecting dig to Real Browser Requests

When you type google.com in your browser:

  • The browser is doing what dig google.com shows

  • DNS resolution happens first

  • Only after getting the IP does HTTP/HTTPS start

No DNS = No website loading.


Why NS Records Matter

NS records tell:

  • Who is responsible for a domain

  • Where DNS queries should go next

Without NS records:

  • DNS resolution would break

  • The chain of trust would be lost

That’s why NS records are critical in system design.


Simple Mental Model to Remember

Think of DNS like asking directions:

  1. Ask city map (root)

  2. Ask area guide (TLD)

  3. Ask house owner (authoritative)

  4. Get exact address (IP)