What happens when you type www.google.com?

What happens when you type www.google.com?

Practical deep dive into finding IP address of a domain using root servers.

  • When you write a domain name in your search address browser finds the IP address using DNS servers, but how does the client find the IP address of the DNS servers? ultimately it starts with root servers. There is a well-known list of root DNS servers maintained by IANA. (NOTE: this article assumes that the reader has a basic knowledge of DNS, IP address, and how the internet works in general.)

  • we can send DNS requests to any root server to get an IP address. You can find a list of root servers with their IPv4 and iPv6 addresses here.

  • we will use the IP address of a.root-servers.net to find the IP address of google.com. (NOTE: if you are a Windows user you need to install dig first.)

  • the command for finding the IP address of a domain from a given name server using dig is dig [ip-address-of-name-server] [hostname]

  • Type dig @198.41.0.4 www.google.com in your terminal (make sure that the IP address that you write is present on the IANA website) and you will get output that looks something like this

  • Now, let's understand the output step by step.

HEADER AND AUTHORITY SECTION

Here, if you look into the flags section it says that we have queried 1 request and it did not find the answer but instead, it returned 13 authorities that know the IP address of all .com domains.

ADDITIONAL SECTION

  • The second part is the additional section where we have the IP addresses of all top-level .com domain servers are mentioned in the authority section.

  • Now select any IP address from the additional section and type dig @.com-ip-address www.google.com (replace .com-ip-address with the IP address from the additional section) which will perform a DNS lookup on .com authoritative name server.

  • This request also did not give the IP address of google.com instead it returned the authority name server of google.com

  • So, now we will do the DNS lookup in one of the authority name servers of google.com dig @google.com-name-server-ip-address www.google.com (replace google.com-name-server-ip-address with the IP address from the additional section)

  • Finally, we have our answer. google.com points to the 142.250.205.228 IP address.

  • In reality, our computer does not need to do all these things instead, it will do the DNS lookup in our caching server. in mac, you can find your caching server from system preferences > network

  • On my computer DNS server is configured to the IP address 192.168.0.1 so if I do dig www.google.com it will fetch the IP address from the cache DNS server.

  • As you can see if I use the dig command without a name server it will be a DNS lookup from caching DNS server.

  • Thank you for reading this article. if you have any doubt, please write them in the comment section and you can also follow me on Twitter.