Skip to main content

Command Palette

Search for a command to run...

How DNS Resolution Works ?

Published
5 min readView as Markdown
M

A developer who likes to builds on his ideas ..


DNS Resolution Explained Using dig (Beginner-Friendly)

What is DNS and why name resolution exists

Humans remember names.
Computers communicate using numbers (IP addresses).

When you type:

google.com

Computers reads:

142.250.xxx.xxx

DNS (Domain Name System) exists to translate names → IP addresses.

Think of DNS as the internet’s phonebook:

  • You look up a name

  • DNS gives you the number

Without DNS, you would need to memorize IP addresses for every website.


Why DNS is not one big database

People confuse DNS only being a database but its not that.

DNS is:

  • Distributed

  • Hierarchical

  • Globally scalable

No single server knows everything.

Instead, DNS resolution happens in layers:

Root → TLD → Authoritative

Understanding this hierarchy is the key to understanding DNS.


DNS Resolution

Explaining DNS Resolution. DNS resolution, or Domain Name System… | by  soulaimaneyahya | Medium

The resolution process typically involves four types of servers working in a chain:

  • Recursive Resolver (Recursor): The "librarian" that receives the initial query from your device and manages the hunt for the IP address by querying other servers.

  • Root Nameserver: The first stop in the hierarchy; it directs the resolver to the specific Top-Level Domain (TLD) server (e.g., .com or .org).

  • TLD Nameserver: Hosts the registry for a specific domain extension and points the resolver to the domain's authoritative nameserver.

  • Authoritative Nameserver: The final stop that holds the actual DNS records (like the IP address) and provides the definitive answer to the resolver. What is the dig command?


dig (Domain Information Groper) is a DNS diagnostic tool.

It lets you:

  • Ask DNS servers questions directly

  • See how name resolution works

  • Debug DNS issues

Browsers hide DNS details.
dig reveals them.


DNS hierarchy (mental model first)

Image

Image

DNS works like this:

  1. Root name servers know where TLD servers are

  2. TLD name servers know where authoritative servers are

  3. Authoritative name servers know the final answer

Let’s walk through this step by step using dig.


dig . NS — Root name servers

Command:

dig . NS

What this asks:

“Who are the name servers for the DNS root?”

What you learn:

  • These servers sit at the top of DNS

  • They don’t know IPs for websites

  • They only know where TLD servers are

Key insight:

Root servers don’t resolve domains.
They point you in the right direction.


dig com NS — TLD name servers

Command:

dig com NS

What this asks:

“Who manages .com domains?”

What you learn:

  • .com is a Top-Level Domain (TLD)

  • These servers know which authoritative servers handle each .com domain

Key insight:

TLD servers don’t know Google’s IP either.
They know who is responsible for google.com.


dig google.com NS — Authoritative name servers

Command:

dig google.com NS

What this asks:

“Who is authoritative for google.com?”

What you learn:

  • These servers are owned by Google

  • They hold the actual DNS records

  • This is where truth lives

Key insight:

Authoritative servers give final DNS answers.


  1. Recursive resolver asks root servers

  2. Root points to .com TLD servers

  3. TLD points to Google’s authoritative servers

  4. Authoritative server returns IP address

  5. Resolver caches the result

  6. Browser connects to the IP

You see only the final answer, but all layers were involved.


What NS records actually represent

An NS record answers one question:

“Who is responsible for this domain?”

  • Root NS → responsible for TLDs

  • TLD NS → responsible for domains

  • Domain NS → responsible for DNS records

NS records do not point to IPs.
They point to authority.


Where recursive resolvers fit in

Your browser does not run all these dig steps.

Instead:

  • Your system asks a recursive resolver (ISP, Google, Cloudflare)

  • The resolver performs all the steps

  • Results are cached for speed

Image

Image

That’s why DNS is:

  • Fast

  • Scalable

  • Efficient


Connecting this to real browser requests

When you type:

https://google.com

Your browser:

  1. Uses a recursive resolver

  2. Gets the IP via DNS hierarchy

  3. Opens a TCP connection

  4. Sends an HTTP request

DNS resolution always happens before HTTP.


Why dig matters for developers

dig command-line tool is like opening the hood of a car to see how the engine is actually running, rather than just looking at the dashboard. For developers, it is an essential tool for verifying that the "phonebook of the internet" is working correctly.

Here is why dig matters for your daily development work:

  • Verifies Real Records: Unlike a browser, which might show you an old version of a site due to its internal cache, dig queries DNS servers directly. This ensures the IP address you see is exactly what the DNS server is currently sending out.

  • Troubleshoots "Site Down" Issues: If a website isn't loading, dig helps you pinpoint if the problem is a broken DNS record (like a missing A record), a server outage, or a configuration error at your domain registrar.

  • Tracks DNS Propagation: After you update your DNS settings, it can take time for those changes to spread across the world. You can use dig @8.8.8.8 to check what Google's servers see versus what your local provider sees, helping you confirm if your changes are "live" yet.

More from this blog

M

Manas.dev_Blogs

13 posts

Beginner-friendly blogs on Git, Networking, and Web fundamentals.