Skip to main content

Command Palette

Search for a command to run...

How DNS Resolution Works

Updated
4 min read
How DNS Resolution Works

When you open any website on a browser, do you know how it opens? Every website is hosted on a server, so to access it, we need the IP address of the server to reach it, like 142.250.182.238. It is hard to remember the IP address of every website, so this is why domain names exist, these are human-friendly, and we can easily remember google.com instead of 142.250.182.238. Think of DNS (Domain Name System) as a phonebook of the internet where every domain name is like the contact name and the IP address is like the contact number. The process of converting a domain name into an IP address is called DNS resolution. And in this article we will understand how DNS resolution actually works.

How does it work?

To understand this, we need to be clear about some terms to understand this whole process:

  1. DNS Resolver: It is a server typically owned by your ISP. It is responsible for the whole process of converting a domain name into an IP address.

  2. Root Server: There are a total of 13 logical root servers in the world, these servers hold the record of the TLD (Top-Level Domains) servers like com, org, uk, in, etc.

  3. TLD Server: TLD server is a server which holds the record of all domains’ authoritative nameserver under a specific TLD like com, org, in, us, etc.

  4. Authoritative Nameserver: It is the final server in the DNS resolution process, which returns the actual IP address to the DNS resolver of a specific domain name. It manages DNS zone of a domain where there is specified the A record, AAAA record, CNAME record, etc.

  5. Web Server: It is the actual server where the website is hosted. It’s IP address is returned to the client by DNS resolver.

This process starts from our browser when we type any address in the address bar, the browser sends a recursive query to the DNS resolver to do the whole work. Browsers don’t take any headache to do the work. The DNS resolver is responsible for getting the IP address of a domain name. It initiates an iterative query; first, it requests the root server. The root server checks the TLD of the domain name, like com, in, us, uk, etc., and returns the IP address of the TLD server to the query resolver. The query resolver sends the request to the TLD server of the domain name, and the TLD server sends the address of the authoritative nameserver. The authoritative name server holds the actual IP address of the domain name as it manages the DNS zone where there are specified A, AAAA, or CNAME records. It returns the IP address to the DNS resolver. The DNS resolver then returns the IP address to the browser, and then the browser is able to request the actual web server for a web page or some resources.

A Practical Guide with dig

DIG is a powerful command-line tool used to interrogate DNS name servers and troubleshoot DNS issues. It is preinstalled on Mac, and for Windows, you can search for how to download dig in Windows.

To get an A record of the domain name, we can run dig {domain-name} +short to get its A record, which is its server IP address.

Note: +short is a flag; it is optional. We can also run these commands without +short flag, but it will give us all the details; to get short, to-the-point details, +short is used.

To get other records, we can specify the record, like NS.

We can also check these details for root servers. To check the nameservers of root, we can run dig . NS +short (.) means root server here.

These are the nameservers of all the 13 root servers from A-M.

Similarly, we can check details of the TLD servers. To check for com TLD. Run dig com NS +short command in your terminal.

Now to check the whole process of DNS, you can run command dig {domain-name} +trace it shows us the whole process of how an IP address is returned.

Conclusion

First the browser requests the DNS resolver to get the IP address of the domain name. The DNS resolver makes iterative queries to different servers in the DNS hierarchy, like the root, TLD, and authoritative name server. It finally gets the IP address from the authoritative name server and returns it to the browser.

The DIG command-line tool helps us to interrogate DNS name servers and troubleshoot DNS issues. To check the DNS records of the root, we can use . and for TLD server we can use com, org, etc.

By now you should have solid knowledge about how DNS resolution works. I’m a fellow developer like you trying to explain what I learned; if there is any mistake in this, I’m open for feedback. Thanks

More from this blog

M

Mursaleen's Blog

13 posts