How DNS Resolution Works
So, for us connect to any machine on the internet , we need its IP address. But as the Human being how can we remember the IP address of the machine and there are n number of machines each company has its own servers/ machine where the application is hosted.
We can remember www.google.com more comfortably rather than this 20.142.202.15 IP address.
In this article, we explore how this domain name (www.google.com) and IP address ( 20.142.202.15) mapping actually works.
What is DNS and why name resolution exists
DNS is not a single machine; it’s a global collection of hierarchal system of servers to resolve each part of the namespace.
For many reasons IP address of a site can change. However, the site name remains the same, so you don’t have to look for a new URL with every change.
Billions of sites and DNS resolve them in a distributed system, not a single server.
What is the dig command and when it is used
Understanding DNS requires some real world example. Domain Information Groper (dig) is a DNS diagnostic command line tool used to inspect name servers, query DNS records, and debug DNS issues.
The dig command shows raw DNS response, very useful for learning.

Understanding dig . NS and root name servers
. means the root server and NS looks for name server records. But these servers do not know the IP addresses of domains. Name servers know which TLD servers to ask next.

Understanding dig com NS and TLD name servers
This is where you find the Top Level Domain (TLD). It’s like you’re asking who manages the .com domains?
You get .com TLD name servers like a.gtld-servers.net, b.gtld-servers.net as a response. These servers know which authoritative servers maintain .com domains, but you won’t get IP addresses.

Understanding dig google.com NS and authoritative name servers
This is where we get clost to the IP address.

these four are the Name servers of the google and if we want to get the actual IP address on the the google server is hosted, then we need to use the dig google.com command

Understanding dig google.com and the full DNS resolution flow
Here the A record means that this is the actual IP address of the server and 177ms shows the TTL (time to live) means after this time the cached values refresh.

Conclusion
The below diagram shows the complete flow, form how the domain name mappeing works with all the Authoritative Name servers , Root Servers and the Top level domains servers.




