DEV Community

Hihi
Hihi

Posted on

DNS resolution - How does it work basically?

The process of typing url to browser bar and then enter, wait for a little bit and you get your webpage in front of you seems like to be simple but there's a lot of communication and works between computers under the hood, and more amazingly, these complex stuffs are done in a time counted by just milliseconds!

high-speed-internet

When you type in the url, for example gg.com to browser and go, the browser first will ask the DNS resolver (usually your ISP) if he saved a cached IP address gg.com or not.

  • If he say yes, he will return the IP address to the browser and then the browser can go to that address to fetch assets of gg.com;
  • If not, he has to proceed on finding the url's IP address

That process of IP finding is called DNS resolution.

Find the IP address

Overall, the DNS resolver (now I will call it resolver) has to scope down the zone of searching: he will search for where is containing all the .com domains among others (.net, .co,...) first, then go to that .com domains container and search for gg.com's address and finally go to that final address to retrieve assets.

  1. The resolver asks the first information bar (rootname server) where contains all the .com domains, the RS returns the IP address of the .com container - this container's address is called Top Level Domain server.
  2. The resolver goes to the Top Level Domain server address, asking for the address of gg.com. The TLD server returns the IP address where containing the gg.com domain - This address is called authoritative name server, the information bar knows where gg.com is living.
  3. The resolver go to the Authoritative name server, asking the exact address of gg.com, the ANS return the exact IP address of gg.com.
  4. Having the final IP address of gg.com, the resolver saves that IP address for a limited time (cached), then tell the browser "hey, this is where gg.com lives, go here to find him".
  5. Browser go to that IP address and retrieve gg.com assets.

DNS resolution diagram

Next time when we want to access gg.com, the resolver will check if there's a time-valid cached IP address of gg.com or not, if the cached IP is not obsolete the resolver will return that cached IP to browser, or else it will start the DNS resolution process.

Some takes

  • DNS servers communicate with address in IPs type, not human url.
  • An IP address points to a specific computer containing the url's assets (HTML, CSS, JS files).
  • A certain url can have multiple IP address in ANS, each of these IP address is called A record. When requested, the ANS will choose 1 of these A records and return to resolver. By doing this the loads among servers containing assets of the url can be shared and balanced and avoid failures when one or more of the servers are down. For example: beside 9.9.9.9, the IP address of gg.com can be 8.8.8.8 or 7.7.7.7. We can go to one of them to get the same assets for gg.com

References

Top comments (0)