- Published on
DNS, How DNS Works, Types of DNS Records
- Authors
- Name
- Balaram Shiwakoti
Everything you need to know about DNS for competitive exams.
Introduction to DNS
The Domain Name System (DNS) maps Domain Names to Ip addresses.
It translates human-friendly domain names (e.g.,
psc.gov.np
) into IP addresses (e.g.,202.45.146.225
) which is further used by computers to locate websites.Without DNS, we may have to type '202.45.146.225' in our browser to access loksewa websites.
You can try typing '202.45.146.225' in your browser it will redirect you to loksewa official website.
Why Do We Need DNS?
Human-Friendly Navigation:
- Remembering multiple digit ip address for each website is impractical (e.g.,
202.45.146.225
). - DNS allows us to use simple names like
google.com
orpsc.gov.np
instead of remembering those complex numbers.
- Remembering multiple digit ip address for each website is impractical (e.g.,
Scalability:
- DNS supports millions of domain names and updates them Dynamically as websites change hosting providers.

How DNS Works: Step-by-Step
Let’s break down the DNS resolution process using an example: typing www.psc.gov.np
in a browser.
Step 1: DNS Query
- The browser checks its cache for
www.psc.gov.np
. If not found, it asks the OS for the ip address.
Step 2: Recursive Resolver
- The OS contacts a recursive DNS resolver (usually provided by your ISP).
- The resolver checks its cache. If the record is expired or missing, it proceeds.
Step 3: Root Nameserver
The resolver queries a root nameserver, which directs it to the Top-Level Domain (TLD) server for
.com
.There are total 13 root name servers
You can read more about those name servers from here
Top-Level Domain means the final part of the domain
1) www.google.com → The TLD is .com 2) www.balaramshiwakoti.com.np → The TLD is .np
Step 4: TLD Nameserver
- The TLD server for
.com
provides the authoritative nameserver forpsc.gov.np
.
Step 5: Authoritative Nameserver
- The authoritative server returns the IP address for
www.psc.gov.np
.
Step 6: Response to Browser
- The recursive resolver sends the IP address to the browser, which connects to the web server.
Types of DNS Records
DNS records are instructions stored in DNS servers to manage domain routing. Key types are:
1. A Record
- Purpose: Maps a domain to an IPv4 address.
- Example:
psc.gov.np → 202.45.146.225
.
2. AAAA Record
- Purpose: Maps a domain to an IPv6 address.
- Example:
psc.gov.np → 2001:0db8:85a3::8a2e:0370:7334
.
3. CNAME Record
- Purpose: Redirects one domain to another .
- Example:
www.psc.gov.np → psc.gov.np
.
4. MX Record
- Purpose: Directs emails to a mail server of the website.
- Example:
psc.gov.np → mail.psc.gov.np
.
5. TXT Record
- Purpose: Stores text information (e.g., SPF for email validation).
- Example:
"v=spf1 include:_spf.psc.gov.np ~all"
.
6. NS Record
- Purpose: Specifies authoritative nameservers for a domain.
- Example:
psc.gov.np → bagmati.nitc.gov.np.
.
7. PTR Record
- Purpose: Maps an IP address to a domain (reverse DNS).
- Example:
202.45.146.225 → psc.gov.np
.
DNS Caching and TTL
- Caching: DNS resolvers temporarily store records to reduce lookup time.
- TTL (Time to Live): Specifies how long a record is cached (e.g., 3600 seconds = 1 hour).
DNS Security Considerations
- DNS Spoofing: Attackers redirect users to fake sites by corrupting DNS data.
- DNSSEC: A security protocol that adds cryptographic signatures to DNS records to prevent tampering.
NOTE
- DNS uses UDP for standard queries and TCP for large data transfers .
Some questions asked in loksewa
- What does TTL-0 means → Data packet should be discarded.
- Function of DNS → Maps Domain name to ip address
- Protocol to SECURE DNS → DoH , DoT
- Provides AUTHENTICATION and INTEGRITY for DNS records → DNSSEC