Skip to main content

Command Palette

Search for a command to run...

How DNS Resolution Works

Updated
4 min read
How DNS Resolution Works

When we type www.google.com or any website name into our browser and press Enter, something magical seems to happen, The browser window get refreshed and requested website just open up instantly. It seems simple and effortless, but behind this small action, a well designed system quietly does its job.

Our computer does not understand website names like google.com or anything, It understands IP addresses, such as 192.168.1.1 .

The job of converting a human friendly name into a machine friendly IP address is done by DNS also known as Domain Name System.


What is DNS and Why Name Resolution Exist?

DNS stands for Domain Name System, the simplest way to understand DNS is to think of it as the Phonebook of Internet.

Just like we save a contact in our phone with a name which are easy to identify for us instead of remembering a phone number, similar to that DNS allows humans to use easy name like google.com, facebook.com etc. insted of remembering a long numeric IP addresses.

This process of converting humanize names to Machine level IP addresses is known as Name Resolution.

Name Resolution exist to bridge the gap between human and internet, to make the internet easily accessible for everyone.

Name resolution exist because:

  • It is not possible for humans to remember IP addresses of each website.

  • Computer require exact IP addresses to communicate

  • The internet needs a scalable and global solution

DNS solves this problem by acting as a System which translates names into IP addresses.


How DNS Works in Layers

DNS is not one big server, It is a hierarchical system, divided into layers, where each layer knows a small part of the answer.

Every DNS lookup follow this order :

  1. Root Name Servers

  2. TLD (Top Level Domain) Name Servers

  3. Authoritative Name Server


What Is the dig Command

dig stands for Domain Information Graper. It is a command lined tool used to inspect DNS resolution.

While Browser hide DNS complexity, dig lets us see exactly how DNS works internally. Think of dig as an X-ray machine for DNS.

Uses of dig Command :

  • Debugging DNS issues

  • Learning how DNS resolution works

  • Verifying name servers and records

  • Understanding where a lookup is failing

We can use this dig command with different parameters as mentioned below :

Understanding dig . NS and Root Name Servers

This is the very top layer of the DNS hierarchy. When we want to know about the root of the DNS system, dig . NS command help us to get the answers.

dig . NS

The output displays a list of root name servers.

These servers are not aware about the IP address of a website, they only know where to find TLD servers like .com, .org, .net, .in etc.

Root servers act like a directory, not a database.

Understanding dig com NS and TLD Name Servers

This is the next step in DNS hierarchy. When we want to know details about the Top Level Domain names (.com in this case)

These servers are special, becuase they are final source of truth and they store actual DNS records like A, AAAA, MX etc.

These servers have the real IP address fo website which we are using in command, in our case google.com.

Understanding dig google.com and the Full DNS Resolution Flow

This is the command our system actually care about :

dig google.com

This returns the IP address of google.com.

Behind the scenes, your system’s recursive resolver has already done the hard work :

  1. Asked a root server where .com lives

  2. Asked a TLD server who handles google.com

  3. Asked the authoritative server for the IP address

  4. Cached the answer for faster future lookups


What Are NS Records and Why They Matter

NS (Name Server) records tell DNS that “This domain is handled by these servers” .

They are critical because :

  • DNS id decentralized

  • Responsibility is delegated layer by layer

  • No single server knows everything

Without NS record, DNS delegation would not work, and the internet would not scale.


How Recursive Resolvers Work Behind the Scenes

Your browser does not directly talk to root or TLD servers, Instead, it sends the DNS query to a recursive resolver. A recursive resolver is a DNS server whose job is to find the final answer on behalf of the client.

You can visualize this resolver as a middle layer that sits between your browser and the global DNS system.

(Diagram Flow : Browser → Recursive Resolver → Root Server → TLD Server → Authoritative Server → back to Resolver → Browser)

This recursive resolver is typically operated by:

  • Internet Service Provider

  • Google

  • Cloudflare

The recursive resolver:

  • Walks the DNS hierarchy on your behalf

  • Caches results to improve performance

  • Returns the final IP to your browser

This is why DNS lookups feel instant after the first request.


Connecting DNS to Real-World Browser Requests

Once the browser receives the IP address:

  1. A TCP connection is created

  2. TLS handshake happens (for HTTPS)

  3. HTTP request is sent

  4. The website loads

DNS is only the first step, but without it, nothing else can happen.