Table of contents
1.
Introduction
2.
Why do we need DNS?
3.
Structure of DNS
3.1.
Root DNS Server
3.2.
DNS Record
3.3.
Namespace
3.4.
Name Server
4.
Domain
5.
How does DNS work?
6.
Categories of DNS servers
7.
Process of DNS lookup
8.
Types of DNS queries
9.
What is DNS Caching and How It Works?
9.1.
How It Works:
9.2.
Types of DNS Caching:
10.
Advantages of Using DNS
10.1.
1. Simplifies Access to Websites
10.2.
2. Boosts Performance via DNS Caching
10.3.
3. Supports Domain Aliasing and Load Balancing
10.4.
4. Enhances Scalability with Hierarchical Structure
10.5.
5. Provides Fault Tolerance Through Distribution
11.
Frequently Asked Questions
11.1.
List all layers of the TCP/IP model?
11.2.
Which are the protocols used in the Application layer?
11.3.
What is Half-duplex and Full-duplex mode?
11.4.
List most common network topologies?
12.
Conclusion
Last Updated: Apr 19, 2025
Easy

Domain Name System(DNS)

Author Anant Dhakad
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

DNS is a service that converts a host's name to an IP address. The Domain Name System (DNS) is a distributed database that is implemented as a hierarchy of name servers. It's an application layer protocol that allows clients and servers to send and receive messages.

Domain Name System(DNS)

Why do we need DNS?

There are two ways to identify a host. One by the hostname and another by an IP address. Routers prefer fixed-length, hierarchically structured IP addresses, while people prefer the more mnemonic hostname identification. Furthermore, because IP addresses are not static, a mapping is required to convert a domain name to an IP address. As a result, DNS is used to transform a website's domain name to a numerical IP address.

Structure of DNS

Root DNS Server

A Root DNS Server is the topmost level in the Domain Name System hierarchy. It acts as the first step in translating a human-readable domain name (like www.example.com) into an IP address. When a user types a URL, the request goes to a root server, which directs it to the appropriate Top-Level Domain (TLD) server (e.g., .com, .org). There are 13 sets of root servers globally, handling billions of queries daily and ensuring internet-wide name resolution starts accurately.

DNS Record

A DNS Record is a database entry in DNS servers that maps domain names to specific details like IP addresses. Common types include A (IPv4 address), AAAA (IPv6 address), MX (mail server), and CNAME (alias). Each record contains information such as the domain name, associated value (like IP), TTL (Time to Live), and record type. DNS records are stored in a tree-like hierarchical structure, allowing efficient lookup and management of multiple domain levels.

Namespace

A Namespace in DNS refers to the set of all possible domain names. It can be flat (all names at the same level) or hierarchical, where names are structured in levels (like com, example.com, www.example.com). DNS uses a hierarchical namespace, much like a file system, to allow scalability and avoid name conflicts. This structure makes it easy to delegate control of subdomains and ensures quick and organized resolution from general (TLD) to specific (host) names.

Name Server

A Name Server is a server that responds to DNS queries by translating domain names into IP addresses. There are different types: Authoritative Name Servers hold specific domain records, while Recursive Name Servers fetch information from other DNS servers on behalf of the user. When a browser asks for www.example.com, the recursive server contacts other servers until it finds the IP and returns it to the client. Name servers implement the actual resolution mechanism in the DNS process.

Domain

There are different categories of domains:

1. Generic domain: Examples of generic domains are ‘.com’(commercial), ‘.edu’(educational), ‘.org’(non-profit organization), ‘.mil’(military), ‘.net’(similar to commercial) etc.

2. Country domain: Examples of country domains are ‘.in’(India), ‘.us’(United States), ‘.uk’(United Kingdoms), ‘.au’(Australia), ‘.lk’(Srilanka) etc.

3. Inverse domain: Basically, it is IP to domain name mapping. 

How does DNS work?

Assume that a user's host application (such as a Web browser or a mail reader) needs to convert a hostname to an IP address. The application will use DNS on the client-side to provide the hostname to be translated. (On various UNIX-based platforms, an application uses the function call gethostbyname() to perform the translation.)The DNS on the user's host then takes control, and it sends a query message into the network. All DNS query and reply messages are sent to port 53 as UDP datagrams. DNS in the user's host receives a DNS reply message with the desired mapping after a delay ranging from milliseconds to seconds. This received mapping (IP address) is then passed to the invoking application.

Categories of DNS servers

When a webpage is loaded, four separate DNS servers are involved.

1. DNS recursor: The recursor can be compared to a librarian who is asked to locate a specific book in a library. This server is designed to handle requests sent directly from client machines via web browsers (and other similar applications).

The recursor then makes additional requests to satisfy the client's DNS query.

2. Root Nameserver: The root server is the first stage in converting (resolving) human-readable hostnames to IP addresses. It's similar to a library's index, which points to different book racks. It gives the address set of the concerned TLD servers.

3. TLD (Top-level domain) Nameserver: This server is responsible for classifying websites according to their type. It is the last part of the domain name. TLDs include ‘.com’, ‘.org’, and ‘.net’, among others. This server can be thought of as a particular shelf in a library. 

4. Authoritative Nameserver: This server can be compared to a dictionary on a bookshelf, where words can be translated. In a DNS query, the authoritative server is the final stop. If the authoritative server contains the requested record, it will return the requested hostname's IP address to the DNS recursor (who initiated the request).

Process of DNS lookup

Process of DNS lookup

1. When a user types 'example.com' into a web browser, the query is transmitted over the Internet and received by a DNS recursive resolver.
2. The DNS resolver then queries the root server 
3. The root server then sends the resolver the address of a Top-Level Domain (TLD) DNS server (such as '.com' or '.net'), which keeps the information for a specific domain. When we search for 'example.com,' we are sent to the '.com' TLD.
4. The DNS resolver then queries the ‘.com’ TLD.
5. The TLD server then returns the address of the domain’s authoritative server (Example: example.com)
6. Now the DNS resolver makes a request to the domain’s authoritative server.
7. Authoritative server returns the IP address of the requested hostname, to the DNS resolver.
8. Finally, the DNS resolver sends the requested IP address to the web browser.

The browser can request the web page after the 8 steps of the DNS lookup have returned the IP address for example.com.

Types of DNS queries

Three types of queries occur in a typical DNS lookup. An efficient DNS resolution process can result in a reduction of distance travelled and lookup delay, by using a combination of these queries.

Types of DNS queries are:

1. Recursive Query: A DNS client expects a DNS server (usually a DNS recursive resolver) to respond to a recursive query with either the requested record (IP address) or an error message if the resolver is unable to locate it. 

Recursive Query

Fig: Recursive query in DNS

2. Iterative Query: In an iterative query, a DNS client allows a DNS server to offer the best possible answer. If the queried DNS server cannot find a match for the query name, it will return the address of a DNS server authoritative for a lower level of the domain namespace.

After that, the DNS client will query the referral address. This operation continues along the query chain with other DNS servers until an error or timeout occurs.

Iterative query in DNS

Fig: Iterative query in DNS

3. Non-Recursive Query: This type of query occurs when the requested mapping is already stored in the cache memory. That is, when a DNS resolver queries a DNS server, it returns the desired mapping without further redirecting to some other server (because that mapping was already in the cache memory of the DNS server).

You can also read about mime protocol.

What is DNS Caching and How It Works?

DNS caching is the process of storing previously resolved domain name queries temporarily to speed up future requests. Instead of querying the DNS server every time, cached results allow quicker domain-to-IP resolution.

How It Works:

  1. When you visit a website, your device checks for cached DNS records before sending a new request.
  2. Cached data includes domain names and their corresponding IP addresses.
  3. Each record has a TTL (Time to Live) value that determines how long it remains valid in the cache.
  4. Caching reduces DNS lookup times, improves browsing speed, and decreases the load on global DNS servers.

Types of DNS Caching:

  1. Browser-Level Caching: Most modern browsers cache DNS results for visited domains, reducing lookup time for frequent sites.
  2. Operating System-Level Caching: The OS maintains a local DNS cache (e.g., via dnsmasq or nscd) to serve multiple apps quickly.
  3. ISP/Recursive Resolver-Level Caching: Internet service providers cache queries for shared use among users, further minimizing repeated external DNS lookups.

Advantages of Using DNS

The Domain Name System (DNS) plays a vital role in making the internet user-friendly and scalable. It translates human-readable domain names into machine-readable IP addresses.

1. Simplifies Access to Websites

DNS allows users to remember easy-to-type domain names (like google.com) instead of numeric IP addresses (like 142.250.182.78), enhancing usability and accessibility.

2. Boosts Performance via DNS Caching

Cached DNS results reduce query time, making websites load faster for repeat visits. This improves both user experience and network efficiency.

3. Supports Domain Aliasing and Load Balancing

DNS enables CNAME records that point multiple domain names to a single server or distribute traffic across several servers, improving reliability and availability.

4. Enhances Scalability with Hierarchical Structure

DNS’s tiered architecture (root, TLD, domain) allows billions of domain names to coexist and be efficiently resolved globally.

5. Provides Fault Tolerance Through Distribution

With multiple DNS servers around the world, the system ensures high availability and continued operation even if some servers go offline.

Frequently Asked Questions

List all layers of the TCP/IP model?

The layers in the OSI model are:
1. Physical layer

2. Data link layer

3. Network layer

4. Transport layer

5. Application layer

Which are the protocols used in the Application layer?

Several protocols are used in the Application layer which includes DNS, SMTP, POP, FTP, HTTP etc.

What is Half-duplex and Full-duplex mode?

Both the devices can act as a sender or receiver in half-duplex mode. But at a time, only one device can transmit data over the link.

Full-duplex mode is bi-directional, i.e., both devices can send or receive data simultaneously.

List most common network topologies?

The most common network topologies are:
1. Mesh topology

2. Bus topology

3. Star topology

4. Ring topology

Conclusion

Cheers if you reached here!! 

In this article, we discussed the DNS(Domain Name System), how it works, different steps involved in resolving a hostname into an IP address.

Recommended Readings:

Live masterclass