How DNS Works

How DNS Works

What happens when you type https://www.google.com in your browser and press Enter?

Before diving deeper into how DNS works, let's first look at what is DNS.

What is DNS?

DNS stands for Domain Name System. It is a hierarchical decentralized naming system that is used to translate human-readable domain names, such as www.google.com, into IP addresses, which are unique numerical identifiers used by computers to locate resources on the internet.

The DNS system works by organizing domain names into a hierarchy of authoritative name servers. These name servers store information about domain names and their corresponding IP addresses. When a user enters a domain name in their web browser, the browser sends a DNS query to a local DNS resolver, which then recursively queries authoritative DNS servers until it finds the IP address associated with the requested domain name.

DNS plays a critical role in the functioning of the internet, as it enables users to access websites and other internet resources using human-readable domain names rather than having to remember numerical IP addresses. It also allows website owners to change the IP addresses associated with their domain names, without requiring users to update their bookmarks or other links.

In addition to translating domain names into IP addresses, DNS also supports other types of resource records, such as mail exchange (MX) records and service (SRV) records, which are used to specify the mail servers and other services associated with a domain name.

How does DNS Works

How does the DNS work when I type www.google.com on my web browser? A lot of things happens behind the scene to enable you to access the site.

  1. The first thing that happens is that your web browser checks its local cache to see if it has a cached copy of the DNS information for "google.com". If it does, it uses that information to connect to the website.

  2. If there is no cached DNS information, the web browser sends a DNS query to a local DNS resolver to obtain the IP address of the Google website. The local DNS resolver may have the IP address cached, or it may need to query other DNS servers to obtain the information.

  3. If the local DNS resolver does not have the IP address for "google.com" in its cache, it sends a DNS query to the root DNS servers. The root DNS servers are the highest level of the DNS hierarchy and maintain information about the top-level domains such as .com, .org, .net, etc.

  4. The root DNS server does not have the IP address for "google.com" either, but it does know the IP address of the DNS server responsible for the .com domain. It returns the IP address of the .com DNS server to the local DNS resolver.

  5. The local DNS resolver then sends another DNS query to the .com DNS server, asking for the IP address of "google.com".

  6. The .com DNS server does not have the IP address for "google.com" either, but it does know the IP address of the DNS server responsible for the "google.com" domain. It returns the IP address of the "google.com" DNS server to the local DNS resolver.

  7. The local DNS resolver then sends a final DNS query to the "google.com" DNS server, asking for the IP address of "google.com".

  8. The "google.com" DNS server has the IP address for "google.com" in its cache, so it returns the IP address to the local DNS resolver.

  9. The local DNS resolver caches the IP address for "google.com" and returns it to your web browser.

  10. Once the IP address of the Google website is obtained, the web browser establishes a TCP/IP connection with the Google web server at that IP address.

  11. Note: If the google.com web server is sitting behind a load balancer, then all requests would first hit the load balancer.

  12. The web browser then sends an HTTP request to the Google web server, asking for the webpage specified by the URL "google.com".

  13. The Google web server responds with an HTTP response containing the HTML, CSS, JavaScript, and other resources required to display the Google webpage in your web browser.

  14. The web browser receives the HTTP response and renders the webpage in the browser window.

This is how the dns resolve domain names once you hit enter on your keyboard. I will be writing a blog on HTTPS.

Don't forget to like, subscribe and comment down below. Cheers!