Skip to main content

Command Palette

Search for a command to run...

How DNS Resolution Works

Published
5 min read

When you type google.com into your browser and press Enter, the website loads within seconds. It may seem like your browser directly connects to Google’s server.

But that’s not what actually happens.

Behind the scenes, a structured and layered system works in milliseconds to convert that human-friendly name into a machine-friendly IP address. That system is called DNS (Domain Name System).

DNS is often described as the “phonebook of the internet.”

What is DNS?

DNS (Domain Name System) is responsible for translating domain names into IP addresses.

Humans prefer names like:

But computers do not understand names. They communicate using numbers, specifically IP addresses.

So DNS performs this translation:

google.com → 142.250.190.46

Without DNS, we would have to remember numeric IP addresses for every website we visit.

What is an IP Address?

An IP (Internet Protocol) address is a unique numerical identifier assigned to every device connected to the internet.

Think of it like a home address:

  • If someone wants to send you a parcel, they need your address.

  • If one computer wants to send data to another, it needs the destination IP address.

Every internet request includes:

  • The destination IP

  • The sender’s IP (so the response can return)

Why DNS Name Resolution Exists

DNS exists for three major reasons:

1. Human Convenience

It is easier to remember names than long numbers.

2. Computer Communication

Computers require IP addresses to exchange data.

3. Scalability and Flexibility

A domain name can point to different IP addresses over time without users noticing any change.

For example, if Google changes its servers, the IP may change but users will still type google.com.

Understanding the dig Command

dig stands for Domain Information Groper.

It is a command-line tool used to manually query DNS records.

When you type a URL in your browser, DNS resolution happens silently in the background. The dig command allows us to inspect this process step by step.

Why Use dig?

You can use dig to:

  • Check DNS records

  • Verify hosting changes

  • Troubleshoot DNS issues

  • Inspect authoritative name servers

  • Measure query time

  • View TTL (Time To Live)

dig google.com

This command retrieves the DNS A record (IPv4 address) of google.com.

DNS Resolution Happens in Layers

DNS does not work in one step. It follows a hierarchical structure:

The Role of the Recursive Resolver

When you enter google.com, your computer does not directly contact the root server.

Instead, it contacts a Recursive Resolver, usually provided by:

  • Your ISP

  • Or a public DNS service like 8.8.8.8

The recursive resolver’s job is to find the correct IP address on your behalf.

It performs the entire lookup process and returns the final answer to your browser.

Root Name Servers

Root servers are the top level of the DNS hierarchy.

dig . NS

The dot (.) represents the DNS root.

Root servers:

  • Do not store IP addresses of websites.

  • They only direct the query to the correct TLD server.

For example, they respond with:

“I don’t know the IP of google.com, but ask the .com TLD server.”

There are 13 logical root server clusters worldwide.

TLD Name Servers (.com, .in, .org)

dig com NS

TLD stands for Top-Level Domain.

TLD servers:

  • Manage domain extensions like .com, .net, .org

  • Do not provide the IP address directly

  • Provide the authoritative name servers for the domain

For google.com, the TLD server responds:

“Ask Google’s authoritative name server.”

Authoritative Name Servers

Command: dig google.com NS

Authoritative servers store the actual DNS records of a domain.

These records include:

  • A record (IPv4)

  • AAAA record (IPv6)

  • MX record (Mail server)

  • CNAME record

  • TXT records

This is the final source of truth for the domain’s IP address.

Full DNS Resolution Flow (Example: google.com)

Command: dig google.com

Step-by-step resolution:

  1. Browser asks the recursive resolver.

  2. Resolver queries the root server.

  3. Root server points to .com TLD server.

  4. TLD server points to Google’s authoritative server.

  5. Authoritative server returns the IP address.

  6. Resolver sends the IP back to the browser.

  7. Browser connects to that IP address.

Only after this process does the website load.

Understanding TTL (Time To Live)

In dig output, you will see a value called TTL.

TTL determines how long the DNS response can be cached.

For example: TTL = 300

This means the resolver will remember the result for 300 seconds (5 minutes) before asking again.

Caching improves performance and reduces load on DNS servers.

What Are NS Records and Why They Matter

NS stands for Name Server.

An NS record tells the internet:

“These servers are responsible for this domain.”

Why NS records are important:

  • At least two name servers are recommended for redundancy.

  • If one server fails, the other can respond.

  • They define where DNS records are hosted.

Without correct NS records, your domain cannot resolve.

How This Connects to Real Browser Requests

When you open a website in your browser:

  • DNS resolution happens first.

  • Then the browser connects to the returned IP.

  • Then HTTP/HTTPS communication begins.

DNS is always the first step before any web request is made.

Final Summary

DNS is a foundational component of the internet.

  • Converts domain names into IP addresses

  • Works in a hierarchical structure

  • Uses recursive resolvers for efficiency

  • Relies on root, TLD, and authoritative servers

  • Uses caching (TTL) for performance

Tools like dig allow us to visualize and understand this entire process.

Next time you type google.com, remember:

Within milliseconds, a globally distributed DNS infrastructure works together to locate the correct server.