How Domain Name Service (DNS) Works
Have you ever wondered how your browser knows where to find a website when you type in its name? Or how your email app can send messages to anyone in the world? The answer is Domain Name Service (DNS), a system that translates human-friendly names into computer-friendly addresses.
DNS is like a phone book for the internet. It maps domain names, such as www.example.com, to IP addresses, such as 192.168.1.1, that identify the location of the servers that host the websites or services. Without DNS, you would have to memorize and type in these long and complex numbers every time you want to visit a website or send an email.
But how does DNS work exactly? Let’s take a look at the steps involved in resolving a domain name to an IP address.
Step 1: OS Recursive Query to DNS Resolver
When you enter a domain name in your browser, such as www.google.com, your operating system (OS) sends a recursive query to a DNS resolver, which is a server that acts as an intermediary between your device and the DNS system. The resolver is usually provided by your internet service provider (ISP) or configured by your network administrator.
Step 2: DNS Resolver Iterative Query to the Root Server
The resolver does not know the IP address of www.google.com, so it sends an iterative query to one of the root servers, which are the authoritative servers for the top-level domains (TLDs), such as .com, .org, .net, etc. There are 13 root servers around the world, each with multiple copies for redundancy and load balancing.
Step 3: Root Server Response
The root server does not know the IP address of www.google.com either, but it knows which server is responsible for the .com TLD. It returns a referral to the resolver with the address of that server.
Step 4: DNS Resolver Iterative Query to the TLD Server
The resolver then sends another iterative query to the .com TLD server, asking for the IP address of www.google.com.
Step 5: TLD Server Response
The .com TLD server does not know the IP address of www.google.com, but it knows which server is responsible for the google.com domain. It returns another referral to the resolver with the address of that server.
Step 6: DNS Resolver Iterative Query to the Google.com NS
The resolver then sends another iterative query to the google.com name server (NS), asking for the IP address of www.google.com.
Step 7: Google.com NS Response
The google.com NS knows the IP address of www.google.com and returns it to the resolver.
Step 8: DNS Resolver Response to OS
The resolver finally has the answer and sends it back to the OS, which passes it to the browser.
Step 9: Browser Starts TCP Handshake
The browser then uses the IP address to initiate a TCP handshake with the web server that hosts www.google.com and requests the web page content.
As you can see, DNS involves multiple queries and responses across different servers and networks. This process can take anywhere from a few milliseconds to several seconds, depending on various factors such as network latency, server availability, caching, etc. To speed up this process and reduce network traffic, DNS relies on caching mechanisms that store previous queries and responses locally or remotely for future use.
DNS is an essential component of the internet infrastructure that enables us to access websites and services using simple and memorable names. It also supports other functions such as load balancing, security, privacy, etc. By understanding how DNS works, you can better appreciate its importance and complexity.
Subscribe to my newsletter
Read articles from Darsh Patel directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by