DEV Community

Cover image for 🔎Behind the Scenes of DNS: How the Internet Finds Websites for You!
Balakumaran K
Balakumaran K

Posted on

🔎Behind the Scenes of DNS: How the Internet Finds Websites for You!

📢 Ever wondered how you access websites without memorizing complex IP addresses? That’s where DNS (Domain Name System) comes in!

Imagine if, instead of typing “Google.com,” you had to enter 142.250.190.78 every time. Sounds complicated, right?

That’s why DNS acts as the internet’s phonebook, converting user-friendly domain names into machine-readable IP addresses, allowing seamless web navigation.

This article breaks down the DNS process step by step, explaining what happens behind the scenes when you enter a website URL into your browser.


What is DNS?

The Domain Name System (DNS) is a hierarchical, decentralized system that translates human-readable domain names (e.g,www.google.com) into numerical IP addresses (e.g., 142.250.190.78).

💡 Think of DNS like your smartphone’s contact list:

Instead of memorizing phone numbers, you just tap a saved contact name to call someone.Similarly, instead of entering an IP address, you type a domain name, and DNS finds the correct website.


How DNS Works Behind the Scenes

Whenever you type a website URL (e.g., www.google.com) into your browser, a complex sequence of events unfolds in milliseconds. Here’s a step-by-step breakdown of the process:

Step 1: Browser Checks Cache

Before asking an external DNS server, the browser first checks locally.

✅️ If the IP address is found in the cache → Skip DNS lookup & proceed to Step 7.

❌️ If NOT found → Initiate DNS resolution (Step 2).

Browser Cache :

The browser cache is a temporary storage location on your device where your web browser saves copies of web pages, images, stylesheets, scripts, and other resources. The purpose of caching is to speed up loading times and reduce bandwidth usage when you revisit websites.

How Caching Works

When you visit a website for the first time:

  • Your browser requests the webpage from the web server.
  • The server sends back the requested resources (HTML, CSS, JavaScript, images).
  • The browser stores these resources in its cache along with metadata, including the expiration date, so it knows how long to keep them.

Step 2: Contacting the DNS Resolver

If the IP address is not cached, the request is sent to a DNS Resolver (usually provided by your ISP or public DNS servers like Google’s 8.8.8.8 or Cloudflare’s 1.1.1.1).

The Resolver’s job is to find the correct IP address for www.google.com.

It first checks its own cache for the record.

✅️ If found → Return IP & proceed to Step 7.

❌️ If NOT found → Forward the request to the Root DNS Server (Step 3 ).

Step 3: Querying the Root DNS Server

Root DNS Servers are the foundation of the DNS hierarchy. There are 13 sets of Root Servers worldwide, managed by ICANN. They don’t store IP addresses but know where to find them.

🔗 Root Server’s job:

If asked for www.google.com, it says: “I don’t have the exact IP, but I know the TLD Server for .com domains!”

Redirects the request to the appropriate TLD Server (Step 4).

Step 4: Querying the Top-Level Domain (TLD) Server

A Top-Level Domain (TLD) Server is a specialized DNS server responsible for managing domain names that belong to a specific TLD category, such as:

  • Generic TLDs (gTLDs) → .com, .org, .net, .info, etc.
  • Country Code TLDs (ccTLDs) → .uk (United Kingdom), .in (India), .jp (Japan), etc.
  • Sponsored TLDs (sTLDs) → .gov (Government), .edu (Education), .mil (Military), etc.

🔗 TLD Server’s job:

If asked for www.google.com, it says: “I don’t have the full IP, but I know the Authoritative DNS Server that does!”

Redirects the request to the correct Authoritative DNS Server (Step 5).

Step 5: Fetching the IP from the Authoritative DNS Server

An Authoritative DNS Server is the server that holds the actual DNS records for a specific domain.
This is the final step in DNS name resolution.
The Authoritative DNS Server holds the actual DNS records for example.com.

It provides the final answer: “The IP address of www.google.com is 192.168.1.100.

🔗 It sends the resolved IP back to the DNS Resolver (Step 6).

Step 6: DNS Resolver Caches & Returns IP

The DNS Resolver now stores the IP address in its cache to speed up future requests.

✅ If another user asks for www.example.com soon, it doesn’t repeat the full process.

The cached result is used instead (reducing lookup time).

🔗 The resolved IP is sent to the browser (Step 7).

Step 7: Browser Receives the IP Address

Now, the browser knows the correct IP address and can initiate communication with the web server.

🔗 The browser proceeds to Step 8.

Step 8: Browser Connects to the Web Server

Finally, the browser: Uses the HTTP(S) protocol to establish a connection. Sends a request for the webpage. The web server responds with HTML, CSS, JavaScript, and other content.

🎉 The website is loaded on your screen!

🛠️ Try These DNS Tools!

1️⃣ Check DNS Records nslookup google.com
2️⃣ Use dig for detailed lookup dig google.com
3️⃣ Check your current DNS Resolver nslookup -type=ns .

🚀 Next time you visit a website,remember: There’s a whole system working in milliseconds to make it happen!

Top comments (0)