Skip to main content

Command Palette

Search for a command to run...

How DNS Resolution Works

Updated
4 min read

What Is DNS and Why Name Resolution Exists

Computers don’t understand names like google.com.
They understand IP addresses like 142.250.183.14.

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

Simple definition:

DNS is the internet’s phonebook.

You remember names.
Computers use numbers.
DNS connects the two.


Why DNS Is Needed (Real-World Analogy)

Think of calling someone:

  • You search a name in your contacts

  • Your phone finds the number

  • The call connects

DNS works the same way:

  • You type a domain name

  • DNS finds the IP address

  • Browser connects to the server


What Is the dig Command

dig stands for Domain Information Groper.

It is a diagnostic tool used to:

  • Inspect DNS resolution

  • See which name servers are involved

  • Debug DNS issues

  • Understand how name resolution works step by step

Simple idea:

dig lets you ask DNS questions directly from the terminal.


Where dig Fits in the Big Picture

Image

Image

Image

Browsers do DNS automatically.
dig lets you see it manually.


DNS Resolution Happens in Layers

DNS is not one server.
It is a hierarchy.

Order:

  1. Root name servers

  2. TLD name servers (.com, .org, etc.)

  3. Authoritative name servers (for the domain)

This layered design keeps DNS:

  • Scalable

  • Fast

  • Reliable


DNS Hierarchy (Mental Model)

Image

Image

Image

Each layer answers only what it knows and points to the next.


Understanding dig . NS (Root Name Servers)

Command:

dig . NS

What this asks:

“Who are the name servers for the root (.) of DNS?”

What you learn:

  • These are the top-level servers

  • They don’t know IPs for websites

  • They only know where TLD servers are

Key idea:

Root servers are the starting point of DNS, not the end.


Understanding dig com NS (TLD Name Servers)

Command:

dig com NS

What this asks:

“Who manages the .com domain?”

What you learn:

  • These servers manage all .com domains

  • They don’t know google.com’s IP

  • They know which servers are responsible for it

Key idea:

TLD servers narrow the search.


Understanding dig google.com NS (Authoritative Servers)

Command:

dig google.com NS

What this asks:

“Which servers are authoritative for google.com?”

These name servers:

  • Belong to Google

  • Contain the actual DNS records

  • Know the real IP addresses

Key idea:

Authoritative servers give final answers.


What NS Records Represent (Important)

NS (Name Server) records say:

“These servers are responsible for this domain.”

Why NS records matter:

  • They define authority

  • They enable delegation

  • They make DNS distributed

Without NS records, DNS cannot scale globally.


Understanding dig google.com (Full DNS Resolution)

Command:

dig google.com

What happens behind the scenes:

  1. Resolver asks root servers

  2. Root points to .com servers

  3. .com points to Google’s authoritative servers

  4. Authoritative server returns the IP address

Image

Image

Image

dig shows you the final answer, but the resolver already did the full journey.


Recursive Resolver (The Hidden Worker)

Your system uses a recursive resolver (ISP, router, or public DNS).

Its job:

  • Perform all DNS steps for you

  • Cache results

  • Return the IP quickly

You rarely see it, but it does most of the work.


Mapping dig Commands to DNS Lookup Stages

Image

Image

Image

CommandDNS Layer
dig . NSRoot servers
dig com NSTLD servers
dig google.com NSAuthoritative servers
dig google.comFinal resolution

Connecting This to Browser Requests

When you type https://google.com:

  1. Browser asks the OS for IP

  2. OS asks recursive resolver

  3. DNS resolution happens

  4. Browser connects to the IP

  5. HTTP request starts

DNS always comes before HTTP.


Practical Takeaways

  • DNS is a distributed lookup system

  • Resolution happens in layers

  • dig helps you see each layer clearly

  • NS records define who is responsible

  • Browsers hide this complexity, but it still happens


Final Reassurance

You do not need to remember:

  • Server names

  • Output formats

  • All record types

If you understand:

Root → TLD → Authoritative → IP

You already understand DNS better than most beginners.