The Domain Name System (DNS) is a distributed, hierarchical naming system that translates human-readable domain names into IP addresses, allowing devices to communicate over the internet.
- It distributes domain information across multiple DNS servers to ensure scalability and reliability.
- It uses caching to reduce repeated queries and improve response time.
Example: When you enter www.geeksforgeeks.org in a browser, DNS resolves the domain name into an IP address, allowing the browser to connect to the appropriate server.
Structure of DNS
DNS organizes domain names into a hierarchical structure, starting from the root and extending to subdomains.

- Root Domain: The highest level of the DNS hierarchy, represented by a dot (.).
- Top-Level Domain (TLD): The domain extension, such as .com, .org, or .in.
- Second-Level Domain: The level directly below the TLD, such as example in example.com.
- Subdomain: A subdivision of a domain, such as mail.example.com.
A hostname identifies a host or network service, such as www.geeksforgeeks.org.
Types of Top-Level Domains
TLDs are commonly classified into two categories:
- Generic Top-Level Domains (gTLDs): General-purpose extensions such as .com, .org, and .net.
- Country Code Top-Level Domains (ccTLDs): Extensions associated with countries or territories, such as .in, .uk, and .jp.

Components of DNS
Four major components participate in DNS resolution.
Component | Function |
|---|---|
DNS Resolver | Receives client queries and retrieves DNS information. |
Root Name Server | Directs the resolver to the appropriate TLD server. |
TLD Name Server | Provides referrals to the domain's authoritative name servers. |
Authoritative Name Server | Provides authoritative DNS records for a domain. |
Working of DNS (DNS Lookup)
DNS lookup is the process of retrieving DNS records associated with a domain name. A forward lookup typically retrieves the IP address required to establish a network connection.

- User Request: The user enters a domain name in the browser.
- Cache Check: The browser or operating system checks whether the requested DNS information is already cached.
- Resolver Query: If no usable cached record exists, the request is sent to a DNS resolver.
- Root Server Query: The resolver contacts a root server to identify the appropriate TLD server.
- TLD Server Query: The TLD server provides a referral to the domain's authoritative name server.
- Authoritative Server Query: The authoritative server returns the requested DNS record, if available.
- Final Response: The resolver returns the IP address to the client, allowing the browser to establish a connection.
Cached DNS records may allow the resolver to skip some of these steps.
Types of DNS Queries
DNS queries differ based on how a server handles a request.
- Recursive Query: The DNS server performs the required resolution and returns a final response or an error.
- Iterative Query: The DNS server returns available information or a referral to another DNS server.
- Non-Recursive Query: The DNS server responds using available information without performing recursive resolution.
Iterative resolution uses non-recursive queries to obtain answers or referrals from DNS servers.
DNS Record Types
DNS records store information about domain names, network addresses, mail servers, and other services.
Record Type | Description |
|---|---|
A | Maps a domain name to an IPv4 address. |
AAAA | Maps a domain name to an IPv6 address. |
CNAME | Maps an alias to its canonical domain name. |
MX | Specifies mail servers responsible for receiving emails. |
NS | Identifies authoritative name servers for a DNS zone. |
PTR | Maps an IP address to a domain name for reverse DNS lookup. |
TXT | Stores text information for domain verification and email authentication. |
SOA | Stores administrative information about a DNS zone. |
DNS Caching and TTL
DNS caching temporarily stores DNS records in browsers, operating systems, and recursive resolvers to reduce repeated lookups and network traffic.
Time-to-Live (TTL) specifies the maximum duration for which a DNS record can normally be reused from the cache.
- TTL is measured in seconds and originates from the published DNS record.
- A cached record may be removed before its TTL expires.
- Once the TTL expires, a fresh lookup is normally required.
Example: A DNS record with a TTL of 3600 seconds can normally be reused from the cache for up to one hour.
Reverse DNS Lookup
Reverse DNS lookup retrieves a domain name associated with an IP address using PTR records. It performs the opposite operation of a forward DNS address lookup.

- IPv4 reverse lookups use the in-addr.arpa domain.
- IPv6 reverse lookups use the ip6.arpa domain.
- Reverse DNS assists in network troubleshooting, traffic analysis, and email server reputation checks.
Reverse DNS alone does not guarantee sender authenticity.

