Domain Name Resolution

·

3 min read

Domain Name Resolution

Introduction

Imagine a scenario: you want to visit Leetcode to improve your coding skills. You type Leetcode.com into your browser, hit enter and within seconds you are on Leetcode. But have you ever wondered what Leetcode.com is? It's a domain name.

Now let’s take a look into the world of internet communication. How does the world know you? likely by your name. Similarly, on the Internet, every computer is recognized by its unique IP address. Computers and other devices ( your mobile, your laptop, even routers) communicate using IP addresses to identify each other on the Internet.

An Internet Protocol (IP) address is the unique identifying number assigned to every device connected to the internet.

You can check this website out to find IP addresses of your favourite websites !

Now think about all the different websites you visit daily, can you remember every website's IP address? Apparently not. It is difficult to remember when there are nearly billions of them, so we use words (domain names) that are easy to remember.

Just as every device has an IP address, every website also has one. How does this work? Well, websites run on a server which is a physical device connected to the internet. The server has an IP address. So, when you type a domain name like "google.com" into your browser, your computer sends a query to DNS (Domain Name System) to ask for the IP address of this domain name. In return DNS either sends back the IP address or an error if such an entry was not found.

The way these hostnames (domain names) are resolved to their mapped IP address is called Domain Name Resolution.


How Does DNS Resolution Work ?

Step 1 : You enter “thecodehelp.in” into your browser.

The operating system will first check its local DNS cache to see if the IP address for the “thcodehelp.in” is already present. If it is found there is no need for a DNS resolution process.

If not found, then the browser sends a DNS resolution request.

Step 2 : The browser sends a message called a recursive DNS query to the recursive DNS server ( DNS Resolver)

The DNS server will again first check its cache for the IP address. If not found there, the recursive resolver knows who to ask ! All resolvers must know one thing : where to locate the root server.

Step 3 : The recursive resolver will now begin the recursive query process to resolve “thecodehelp.in”. It will ask a series of other servers in this order –

DNS root server → TLD servers → Authoritative servers.

The TLD (top level domain) usually represents an organisation or a geographical location. TLD server examples –

  • .com

  • .in

  • .net

Step 4 : These three servers work together till they find a DNS record with the IP address. Once found, the IP address is sent back to the recursive resolver, and your webpage loads.

If the authoritative server cannot find the IP address, an error message is returned.

Step 5 : The recursive server caches this record so that next time it can directly send the IP address instead of asking other servers.

Even though the whole process sounds lengthy, the DNS resolution process happens very quickly, usually in a fraction of second.