DNS is a system that translates human-readable domain names into IP addresses so computers can communicate over the internet. It works in a hierarchical and distributed manner to efficiently resolve queries. DNS ensures users can access websites without remembering numeric IP addresses. It also improves performance using caching.
- Provides name-to-address resolution
- Uses a hierarchy (Root, TLD, Authoritative servers)
- Improves speed using caching mechanisms
Example: When you enter google.com in a browser, DNS converts it into an IP address (like 142.x.x.x), allowing your system to connect to the correct server.
Working
The DNS process can be broken down into several steps, ensuring that users can access websites by simply typing a domain name into their browser.
- User Input: The user enters a domain name (e.g., www.geeksforgeeks.org) in the browser.
- Local Cache Check: The browser or OS checks its cache for a stored IP address.
- DNS Resolver Query: If not found, the request is sent to a DNS resolver (usually by ISP).
- Root Server Query: The resolver queries a root server, which points to the correct TLD server.
- TLD Server Response: The TLD server directs the resolver to the domain’s authoritative server.
- Authoritative Server Response: The authoritative server returns the actual IP address.
- Final Response: The resolver sends the IP back to the user, and the browser connects to the server.
Structure of DNS
The structure of DNS is hierarchical in nature, enabling scalable and organized domain name resolution across the global Internet.
1. Root:
The topmost level of the DNS hierarchy.
- Represented by a dot (.) at the end of a domain name
- Acts as the starting point of domain resolution
2. Top-Level Domains (TLDs):
The level directly below the root that defines domain extensions.
- Includes extensions like .com, .org, .net, .edu
- Helps categorize domains by purpose or region
3. Second-Level Domains:
The main domain name registered by an organization.
- Appears before the TLD (e.g., "example" in example.com)
- Uniquely identifies a domain under a TLD
4. Subdomains:
Extensions of the main domain used for organization.
- Examples: www, mail, blog
- Helps structure different parts of a website
5. Hostnames:
Identifies specific servers or devices within a domain.
- Examples: web1, mailserver, ftp
- Maps to actual IP addresses using DNS records
Types of Domains
DNS categorizes domain names into different types to organize the global naming system and support both forward and reverse resolution.

1. Generic Domains (gTLDs):
These domains are used for general purposes and are not tied to any country.
- Include extensions like .com, .org, .net, .edu
- Not restricted to any specific country
- Used for commercial, organizational, and educational purposes
2. Country Code Domains (ccTLDs):
These domains represent specific countries or geographic regions.
- Examples: .in (India), .us (USA), .uk (UK), .jp (Japan)
- Managed by respective national authorities
3. Inverse Domains (Reverse DNS):
These domains are used to map IP addresses back to domain names.
- Used for reverse lookup (IP address → domain name)
- IPv4 uses in-addr.arpa
- IPv6 uses ip6.arpa
- Uses PTR (Pointer) records
Domain Name Server
A Domain Name Server is a server that stores DNS records and responds to queries by providing the appropriate information required for domain name resolution.
- Stores DNS records such as A, AAAA, MX, CNAME, NS, and PTR.
- Responds to queries from clients or other DNS servers.
- Operates within the hierarchical DNS structure.
- Can perform either recursive or authoritative functions.
- Enables communication between users and web servers by supplying necessary DNS data.
DNS Lookup
DNS Lookup, also known as DNS Resolution, is the process of converting a domain name into its corresponding IP address so that a device can establish communication with the target server.
Key Components
The key components of DNS work together to resolve domain names into IP addresses efficiently.
1. DNS Resolver:
The component responsible for starting the DNS lookup process.
- Initiates the lookup process
- Acts as an intermediary between the client and DNS servers
2. Recursive Query:
A query where the resolver fetches the complete answer for the client.
- The resolver obtains the final IP address on behalf of the client
- May contact multiple DNS servers to resolve the query
3. Iterative Query:
A query where the resolver gets the best possible answer from each server.
- The resolver receives partial answers or referrals
- Servers may direct it to another DNS server
4. Non-Recursive Query:
A query where the answer is already known or cached.
- The requested record is available in cache
- The server returns the result immediately
Types of DNS Queries
DNS queries are request mechanisms used during DNS lookup to obtain domain-related information from DNS servers.
1. Recursive Query:
The client expects the resolver to return a complete and final answer.
- The resolver performs all lookups on behalf of the client
- Returns the requested record or an error
2. Iterative Query:
The server provides the best possible answer it has.
- Returns the record if available
- Otherwise, gives a referral to another DNS server
3. Non-Recursive Query:
The server already has the required information available.
- Record is present in cache or authority
- Responds immediately without further lookup
DNS Caching
DNS caching is a technique that temporarily stores DNS records to reduce repeated queries and improve resolution efficiency.
- Stores previously resolved domain records locally.
- Reduces response time for future requests.
- Minimizes load on external DNS servers.
- Improves overall network performance.
TTL (Time-to-Live)
TTL defines the duration for which a DNS record is considered valid in cache.
- Specifies how long a DNS record remains stored in cache.
- Defined by the authoritative DNS server.
- Measured in seconds.
- After expiration, a new DNS lookup is required.
Example: If the TTL value is 3600 seconds, the record remains cached for one hour before it must be refreshed.
Reverse DNS Lookup
Reverse DNS Lookup is the process of resolving an IP address to its associated domain name, performing the opposite function of standard DNS resolution.
- Converts an IP address into a domain name.
- Uses special domains such as in-addr.arpa (IPv4) and ip6.arpa (IPv6).
- Relies on PTR (Pointer) records for mapping.

Reverse DNS is commonly used for:
1. Network Diagnostics
Helps in analyzing and troubleshooting network issues.
- Helps administrators identify the domain linked to a specific IP address.
- Assists in traffic analysis and troubleshooting.
2. Email Security
Ensures emails are sent from legitimate sources.
- Used by mail servers to verify sender authenticity.
- Helps reduce spam and fraudulent email activity.
DNS Record Types
Different DNS record types are used to store specific information about a domain.
- A Record: Maps a domain name to its corresponding IPv4 address.
- CNAME Record: Creates an alias that points one domain name to another domain name.
- MX Record: Specifies the mail server responsible for receiving emails for a domain.
- TXT Record: Stores text information used for verification and email authentication purposes.