Domain Name System (DNS)
The Domain Name System (DNS) is a critical component of Internet infrastructure that plays an essential role in connecting users to websites, services, and resources on the World Wide Web. Essentially, DNS is the “phone book” of the internet, converting user-friendly domain names (like www.example.com) into numerical IP addresses (like 192.0.2.1) that computers and network devices use to locate each other on the internet.
The development of DNS began in the early days of the internet, when it was known as ARPANET. In the early 1980s, ARPANET used a centrally managed file called “hosts.txt” to map hostnames to IP addresses. Computers queried this file to obtain the IP addresses associated with domain names. However, as the internet grew rapidly, this approach became unmanageable.
In 1983, Paul Mockapetris and Jon Postel introduced the DNS we know today through RFC 882 and RFC 883, providing a distributed and hierarchical system for domain name resolution. This innovation paved the way for the scalable and efficient DNS architecture that underpins the modern internet.
Domain Name
A domain name is a human-readable label that represents a specific location or resource on the internet. Domain names are structured in a hierarchy separated by dots.
For instance, the domain name www.example.com consists of three parts:
- www - subdomain
- example - second-level domain
- com - top-level domain
Top-Level Domain (TLD)
A Top-Level Domain (TLD) sits at the highest level in the hierarchy of domain names on the internet. It is the final portion of a domain name. TLDs are typically used to indicate the type, purpose, or geographical location of a website. For example, .com is used for commercial entities, .org is generally used for non-profit organizations, .gov for government institutions, and .edu for educational institutions. Additionally, there are country code TLDs (ccTLDs) specific to each country, such as .uk for the United Kingdom and .de for Germany.
In the early days of the internet, TLDs were limited in number and primarily used to denote the type or purpose of a site. However, with the growth of the internet, the necessity for creating and utilizing more TLDs arose. Today, there are hundreds of different TLDs available, including generic TLDs (gTLDs) that can target specific interests, industries, or communities, such as .photography, .guru, .tech. This expansion has made the domain name system more flexible and diverse, allowing users and businesses to better define their web presence.
Types of DNS Servers
We’ve mentioned that the DNS system is like the phone book of the internet. During the process where DNS queries a domain name to obtain an IP address, there are three main players involved:
- Authoritative Name Server
This server is the official source of information for a specific domain. Each domain has at least one authoritative name server that holds the DNS records for that domain. These DNS records include information such as the domain’s IP address, mail servers (MX records), subdomains (CNAME records), and more. At the end of a DNS query process, if this server is reached, the required information is obtained directly and definitively from here.
- Recursive Resolver
When a user wants to access a website, this request first goes to the recursive resolver. The recursive resolver performs the necessary query process on behalf of the user. This process starts with a general referral (starting from root servers) and progresses step by step among various DNS servers until the desired information is found. During this process, the recursive resolver caches any necessary DNS records, speeding up future queries.
- Root Name Servers
These servers sit at the top of the internet’s DNS hierarchy and host the address information for all TLDs (such as .com, .net, .org). If a recursive resolver does not know which TLD server to ask for an address, it first consults the root name servers to start resolving a query. The root name servers provide the initial referral information needed to direct the query to the correct TLD server.
Understanding with an Example
Let’s understand the DNS resolution process in 7 steps:
- DNS Query from User Computer
A user enters a URL, such as www.example.com, into an internet browser. This action causes the user’s computer (client) to create a query for DNS resolution. This query is first sent to the recursive resolver of the user’s Internet Service Provider (ISP).
- Query to ISP’s Recursive Resolver
The recursive resolver receives this query and first checks its own cache for a record of this query. If an appropriate record is found, the resolution process ends here, and the IP address is returned directly to the user. If no record is found in the cache, the recursive resolver carries out a series of steps to resolve the query.
- Query to the Root DNS Server
If no suitable record is found in the cache, the recursive resolver directs the query to a Root Name Server at the top of the DNS hierarchy. The root server provides information about which Top-Level Domain (TLD) DNS Server (e.g., for “.com”) the query should go to.
- Query to TLD DNS Server
With the direction information received from the Root DNS Server, the recursive resolver directs the query to the relevant TLD DNS Server (for example, for “.com”). The TLD server provides the address of the Authoritative Name Server for the desired domain (e.g., “example.com”).
- Query to Authoritative Name Server
The recursive resolver, armed with the obtained information, queries directly to the domain’s Authoritative Name Server. The authoritative server contains the required DNS record, such as the A record (the domain’s IP address) for www.example.com.
- DNS Record Returned to Client
The authoritative name server sends the requested DNS record (IP address) back to the recursive resolver. The recursive resolver then relays this information to the user’s computer, allowing the user to access the desired website through their browser.
- Connection to the Website
The user’s computer uses the obtained IP address to send an HTTP request directly to the website’s server, and the website’s content is presented to the user.