DEV Community

Ida Delphine
Ida Delphine

Posted on

The DNS Demystified

Are you wondering how you are able to reach your favorite website with just a click? This is essentially thanks to the DNS.

What is the DNS?

DNS stands for Domain Name System. Think about it like the internet's address book where all the domain names are mapped to their associated websites. If not for the DNS, you'll have to access any website using their IP address. Imagine trying to memorize the IP addresses of all the websites you know or whenever you need to access a website you maybe have to pull out notes of where you saved the different IP addresses. I will probably never want to look up any website or do any internet-related work. This is exactly why we have domain names. They are human-readable and unique for every website just like IP addresses. Computers do not really understand these domain names though. So picture domain names like a friendly mask for IP addresses.

There are about 4 different DNS servers involved in the lookup of a website. When you make a request to access a webpage, that is considered a query. Firstly, we have the DNS recursor. It is meant for receiving queries from browsers. This is like visiting a library and asking the librarian for a particular book. Secondly, we have the Root nameserver and this is where the DNS resolution (translating host/domain names to IP addresses) actually begins. It points to where the IP address is in the DNS. Thirdly, there is the Top-Level Domain (TLD) nameserver. You know how many websites suffix with .com, .tech, .org, etc? The TLD server finds IP addresses within a specific TLD. Finally, we have the Authoritative nameserver. Picture it like a dictionary with the various domain names (excluding their TLDs) mapped to their IP addresses. It returns the IP address to the DNS recursor.

The DNS look-up sequence

  • User inputs the URL(idadelveloper.com) into the address bar of the browser and and initiates a query over the internet which is received by the DNS recursor resolver.

  • The DNS resolver forwards the query to the root nameserver.

  • The root server responds with the location of the TLD of that domain name of which in the case of idadelveloper.com, it will be .com. Our request will now be directed to the .com TLD.

  • As the resolver makes a request to the .com TLD, the TLD server responds with the IP address for idadelveloper.com's nameserver.

  • The recursor makes another request to this nameserver where the IP address for idadelveloper.com is returned to the recursor from the nameserver.

  • The DNS resolver returns the IP address of this domain name to the browser.

  • The browser now makes an HTTP request to the IP address and the server at that IP address returns the webpage to the browser.

Top comments (0)