Skip to main content

Command Palette

Search for a command to run...

How DNS Resolution Works

Published
4 min read

When you type google.com into your browser, the website opens almost instantly.
But behind the scenes, a lot happens just to find where Google lives on the internet.

This process is called DNS resolution.

In this article, we’ll understand DNS resolution step by step using the dig command and real examples.


What Is DNS and Why Name Resolution Exists

DNS stands for Domain Name System.

DNS exists because it’s easier for humans to remember names instead of long numbers.
It changes website names like google.com into numbers (IP addresses) that computers understand.

Without DNS, we would need to type long IP addresses instead of simple website names.


Introducing dig: A DNS Diagnostic Tool

dig (Domain Information Groper) is a command-line tool used to inspect DNS resolution.

It helps developers:

  • Debug DNS issues

  • Understand how DNS resolution works

  • See which servers answer DNS queries

You can think of dig as a tool to look inside the DNS phonebook.


DNS Resolution Happens in Layers

DNS resolution follows a clear hierarchy:

Root Servers —> TLD Servers (.com, .org, .in) —> Authoritative Servers

Your system’s recursive resolver handles these steps automatically, but dig lets us observe them manually.


Step 1: Root Name Servers

dig . NS

This command asks: “Who manages the root of the internet?”

What happens here:

  • The root servers don’t know IP addresses of websites

  • They only know which servers handle TLDs like .com, .org

Root servers are the starting point of DNS resolution.


Step 2: TLD (Top-Level Domain) Name Servers

dig com NS

This command asks: “Who manages all .com domains?”

What happens here:

  • TLD servers don’t know Google’s IP

  • They know which authoritative servers manage google.com

    TLD servers act like directories for domain categories*.*


Step 3: Authoritative Name Servers

dig google.com NS

This command asks: “Who is responsible for google.com?”

What happens here:

  • You receive Google’s authoritative name servers

  • These servers contain the final DNS records

Authoritative servers give official answers for a domain.


Step 4: Full DNS Resolution

dig google.com

This command shows:

  • The final IP address of google.com

  • The record type (A / AAAA)

  • The server that answered the query

This is the same information your browser needs to load a website.


How Recursive Resolvers Work Behind the Scenes

Your browser does not contact root servers directly.

Instead:

  1. Browser asks the recursive resolver (ISP / system DNS)

  2. Resolver queries:

    • Root servers

    • TLD servers

    • Authoritative servers

  3. Resolver caches the result

  4. Browser receives the IP address


Connecting dig to Real-World Browsing

When you open google.com:

  • Browser → Recursive Resolver

  • Resolver → Root → TLD → Authoritative

  • Resolver returns IP

  • Browser connects to Google’s server

  • Website loads

dig lets us manually observe each of these stages.


Why NS Records Matter

NS (Name Server) records tell DNS:

  • Who is responsible for a domain

  • Where to ask for authoritative answers

Without NS records:

  • DNS resolution cannot move forward

  • Websites and emails will fail


final summary using real life scenario:

DNS works like finding a person in a huge city. You know their name, but not their exact house address. The root name servers act like the city’s main directory office—they don’t know the house but know which area office (TLD) to ask. The TLD servers are like neighborhood offices that know which street office (authoritative server) manages the person’s house. The authoritative servers are the street offices that know the exact house number (IP address). Your recursive resolver is like a personal assistant that goes through all these offices for you, remembers the answer, and tells your browser. Finally, your browser uses the IP address to connect directly to the server and load the website. This way, DNS lets your browser find websites quickly without you ever needing to know the full “address.”


Remember:

DNS resolution may seem complex, but it follows a logical and layered design.

Key takeaways:

  • DNS is the internet’s phonebook

  • dig helps inspect DNS resolution

  • DNS works in layers for scalability

  • Recursive resolvers hide complexity from users

Understanding DNS is essential for web developers, system designers, and DevOps engineers.

How DNS Resolution Works