Skip to main content

Command Palette

Search for a command to run...

How DNS Resolution Works

Updated
3 min read

When you type google.com in a browser, a lot happens behind the scenes before the page loads.
That entire process is called DNS resolution.

Let’s break it down step by step using the dig command.

1. What is DNS and why name resolution exists

Computers don’t understand domain names.
They only understand IP addresses like 142.250.190.14.

DNS (Domain Name System) exists to translate human-friendly names into machine-friendly IPs.

Think of DNS as the internet’s phonebook:

  • Name → Phone number

  • Domain → IP address

Without DNS, we’d have to remember IPs for every website.

2. What is the dig command and when it is used

dig stands for Domain Information Groper.

It is a command-line tool used to:

  • Inspect DNS records

  • Debug DNS issues

  • Understand how name resolution works internally

Unlike browsers, dig shows raw DNS responses.

Example:

dig google.com

3. Understanding dig . NS (Root Name Servers)

Let’s start from the top of the DNS hierarchy.

dig . NS

This asks:

“Who controls the root of DNS?”

The response lists root name servers like:

a.root-servers.net
b.root-servers.net
...

These servers don’t know IPs of websites.
They only know where to find TLD servers.

Root servers are the starting point of every DNS lookup.

DNS hierarchy – Root level

4. Understanding dig com NS (TLD Name Servers)

Next layer: Top-Level Domain (TLD).

dig com NS

This asks:

“Who manages .com domains?”

The answer returns .com name servers (run by Verisign).

TLD servers:

  • Don’t know IP addresses

  • Know which authoritative servers manage a domain

Root → TLD (.com)

5. Understanding dig google.com NS (Authoritative Servers)

Now let’s ask about a specific domain.

dig google.com NS

This returns Google’s authoritative name servers like:

ns1.google.com
ns2.google.com

Authoritative servers:

  • Hold the actual DNS records

  • Are the final source of truth

This is where real answers live.

TLD → Authoritative servers

6. Understanding dig google.com (Full Resolution Flow)

Now the real question:

dig google.com

This returns:

  • A record (IPv4 address)

  • Sometimes AAAA (IPv6)

  • TTL values

Behind the scenes, the resolver does this:

  1. Ask root servers → where is .com?

  2. Ask .com servers → where is google.com?

  3. Ask Google’s authoritative servers → what is the IP?

Your browser never talks directly to root or TLD servers.
A recursive resolver (ISP / Google DNS / Cloudflare) does this for you.

Full DNS resolution flow for google.com

How recursive resolvers fit in

Recursive resolvers:

  • Cache DNS results

  • Reduce latency

  • Protect root/TLD servers from overload

Popular resolvers:

  • 8.8.8.8 (Google)

  • 1.1.1.1 (Cloudflare)

They repeat the root → TLD → authoritative process only when needed.

Recursive resolver interaction

Connecting DNS to real browser requests

When DNS resolution finishes:

  • Browser gets IP address

  • TCP connection starts

  • HTTPS handshake happens

  • HTTP request is sent

DNS is step zero of every web request.

If DNS fails, nothing loads.