Skip to main content

Command Palette

Search for a command to run...

How DNS Resolution Works

Understanding the hidden process that translates website names into computer-readable numbers.

Published
5 min readView as Markdown
How DNS Resolution Works
A

Full-stack developer and startup founder building tech solutions in Ayodhya. Vlogger with 27k+ followers sharing my journey in technology and SaaS.

dig: How the Internet Finds a Website

The dig is not just a command; it is a software in itself. The DIG command is a very useful tool for viewing DNS records or obtaining a lot of information about a website's domain name, such as its IP address, mail server, and much more. To understand how it works, let's say we want to look up the name server or IP address of a website, such as google.com. It immediately sends a request to the DNS server. The server processes this request and sends you the response.

What is DNS, and Why Do We Need This "Name Resolution"?

DNS stands for Domain Name System, a crucial internet service that translates domain names into IP addresses. In simpler terms, just as you find a phone number by searching for a name in your phone book, a domain name server finds the actual address of a website using its name. This name resolution is necessary because computers understand numbers better, while we understand names much better.

Name resolution, as we discussed earlier regarding DNS, is the process of converting a domain name into an IP address. This is a very important process because computers understand numbers, while we prefer to remember names. When you type a domain name into your web browser, the name resolution process begins. It involves several servers that work together to find the correct IP address.

Meet the dig Command: My Magnifying Glass for the Internet

The dig (Domain Information Groper) command is a special tool used to look inside the Internet’s address book, which we call DNS (Domain Name System). Think of the internet as a giant city. When you want to visit a website like google.com, your computer needs to find its exact house number, called an IP Address. The dig command acts like a magnifying glass. It allows you to see every step of the search process. Instead of just seeing the final website, you can see how the internet asks different "offices" for directions until it finds the right one.

Step 1: dig . NS — Talking to the Root Name Servers (The Big Boss)

Every journey on the internet starts at the very top. In the world of DNS, the top is represented by a simple dot (.). When you type dig . NS, you are talking to the Root Name Servers. You can think of these as "The Big Boss" of the internet. They do not know the address of every website, but they know exactly where to send you next. If you are looking for a .com website, the Root Server points you to the right department.

Command:

dig . NS

Example Output:

. 518400 IN NS a.root-servers.net.

. 518400 IN NS b.root-servers.net.

. 518400 IN NS c.root-servers.net.

Step 2: dig com NS — Moving to the TLD Servers (The ".com" Folder)

Once the "Big Boss" gives you directions, you move to the TLD (Top-Level Domain) servers. For example, when you run dig com NS, you are looking into the big folder that holds every single .com website in the world. These servers are like a library section dedicated only to one category. They don't have the final answer yet, but they know who is "in charge" of specific names like Google or Facebook.

Command:

dig com NS

Example Output:

com. 172800 IN NS a.gtld-servers.net.
com. 172800 IN NS b.gtld-servers.net.

com. 172800 IN NS a.gtld-servers.net.

com. 172800 IN NS b.gtld-servers.net.

Step 3: dig google.com NS — Finding the Authoritative Servers (The Final Answer)

Now we reach the final destination. When you run dig google.com NS, you are finding the Authoritative Name Servers. These are the servers owned by the website owner (like Google). These servers have the "Final Answer." They are the only ones that can give you the 100% correct IP address for that domain. This is like finally reaching the specific house you were looking for and asking the person inside for their name.

Command:

dig google.com NS

Example Output:

;; ANSWER SECTION:

google.com. 172800 IN NS ns1.google.com.
google.com. 172800 IN NS ns2.google.com.

(These are the actual servers that belong to Google and hold the final records.)

The Full Picture: How dig google.com Shows the Whole Journey

In the real world, these three steps happen in a split second. However, using dig helps us see the full "map" of the journey. When you use the +trace command, it shows you how the request travels from the Root, through the TLD, and finally to the Authoritative server. It reveals how the internet is not just one big machine, but a huge team of different servers working together. Seeing the "Full Picture" helps you understand that every time you click a link, a global conversation is happening.

Command to see the whole journey:

dig google.com +trace

Why Do Software Engineers Use dig in the Real World?

Software engineers use dig every day because it is a powerful troubleshooting tool. Here is why they love it:

  • Testing Changes: When they move a website to a new server, they use dig to see if the new address is showing up correctly.

  • Fixing Problems: If a website is not opening, they use dig to check if the DNS "directions" are broken or wrong.

  • Checking Email: They use it to verify MX records, which make sure emails are sent to the right place.

  • Speed: It shows how long it takes for a server to respond (Query time), helping them make websites faster.