How DNS Resolution Works
What is DNS
DNS means Domain Name System.It is also called the internet’s phonebook.in very simple words,It is the system that translates website names or human-readable names like(chaicode.com) into machine-readable IP addresses like(192.1.1.1).Our computers dont understand names like google.com chaicode.com they only understand IP addresses.So DNS helps to convert a human-readable names into machine-freindly IP addresses.
Why Name Resolution exists
DNS name resolution exists to minimise the gap between human-friendly domain name and machine-readable IP addresses.for example
Imagine you have to remember this
192.1.1.1
Instead of this:
google.com
That would be very difficult.We humans can’t remember that jibrish thing.This is why DNS exists.
In Simple words:
When humans type websites name like google.com
Computers can’t understand that,they only understand IP addresses like 192.1.1.1.
That’s why name resolution exists because the DNS name resolution converts the name into IP addresses.
What is the dig command and when it is used
dig stands for Domain Information Groper.It is a command-line tool used to find DNS details of a domain name such as:
IP Address
Name Servers
Mail Servers
DNS records
For Example:
dig chaicode.com
//note - if you are Windows users use nslookup command instead of dig.
This command shows:
Which Server(ISP) is responding
The IP address of chaicode.com
Query Time
Understanding dig . NS and root name servers
dig .NS → asks the root server for their NS(Name Server) Records
Root Server → They are the top level server that starts the DNS resolution process
They dont have the IP address of every website but they know where the TLD servers are.
Understanding dig com NS and TLD name servers
dig com NS → asks .com TLD servers for thier NS records.
TLD servers like(.com,.org) knows which authorative servers handles IP addresses of these specific websites.
Basic Flow:

Understanding dig google.comNS and authoritative name servers
dig google.com NS → It shows authorative NS server for google.com.
Authorative name servers are the servers that knows the actual IP address of a domain.
In Simple Words:
dig google.com NS → finds which server knows the real IP of google.
Authorative Server → are the server that actually have the IP address of google.com
Understanding dig google.com and the full DNS resolution flow
When You type google.com in your browser
Your computer → send a query to local DNS resolver.
Resolver → Asks Root Server → Who handles .com
Root server → replies I dont know who handles it but i know where the .com TLD servers are
Root server → asks .com TLD server → It also does’nt know the exact IP → but it knows which authoritative server handles googe.com.
Root server → now asks Authoritative ns server → and it gets the IP
Resolver → returns IP back to your computer → and the browser connects
Example: If you run dig/nslookup google.com command in your cmd then you get this output
Non-authoritative answer:
Name: google.com
Addresses: 2404:6800:4002:804::200e //IPv6 address
142.250.67.78 //IPv4 address