Understanding DNS - How Domain Name System Works

A comprehensive guide to DNS architecture, types of DNS servers, and record types

Featured image



🎯 Overview

Let’s explore how DNS (Domain Name System) works, from basic concepts to detailed operations.

📝 Working Process

  1. User accesses website (www.a.com)
  2. Computer checks local DNS cache
  3. If not in cache, DNS query begins
  4. Root DNS server IP address is obtained
  5. Query sent to Root DNS for TLD server address
  6. Query sent to TLD DNS for Authoritative DNS server address
  7. Query sent to Authoritative DNS for IP address
  8. IP address cached and returned to browser



🔍 What is DNS?

DNS (Domain Name System) is a system that converts human-readable domain names into IP addresses used by computers on the internet.

📊 Types of DNS Servers

🌐 Root DNS Server

- Most critical DNS server in internet infrastructure
- Globally distributed
- Manages root domain names (.)
- Maintained by ICANN
- Provides TLD DNS server information

🏢 TLD (Top-Level Domain) DNS Server

- Manages top-level domains (.com, .org, .edu)
- Processes DNS queries for TLD domains
- Works with domain registrars
- Maintained by ICANN
- Directs to Authoritative DNS servers

🎯 Second-Level DNS Server (Authoritative)

- Typically hosting provider's nameserver
- Contains actual domain-IP mappings
- Final authority for domain information
- Manages specific domain records

🔄 Other DNS Server Types

Recursive DNS Server:
- Performs complete DNS queries
- Contacts other servers as needed

Caching DNS Server:
- Stores previous query results
- Improves query performance
- Can be cleared (ipconfig/flushdns)

Forwarding DNS Server:
- Forwards queries to other servers
- Can cache results

Secondary DNS Server:
- Replicates primary DNS data
- Provides redundancy



📊 DNS Working Process Flowchart

graph TD; A[🌐 User accesses website www.a.com] --> B[🗃️ Check Local DNS Cache]; B -->|Not Found| C[📡 Recursive DNS Query Starts]; C --> D[🌍 Query Root DNS Server for TLD Info]; D --> E[🏢 Query TLD DNS Server for Authoritative Server]; E --> F[🎯 Query Authoritative DNS Server for IP]; F --> G[📥 IP Address Returned to Resolver]; G --> H[📝 Cache IP Address]; H --> I[🔗 3-Way Handshake SYN → SYN/ACK → ACK]; I --> J[📨 Send HTTP Request to Server]; J --> K[📥 Receive HTTP Response]; K --> L[👀 Display Website to User]; %% Alternative Flow B -->|Found in Cache| I;



📝 DNS Record Types

Common DNS Records

A Record:     Domain name → IPv4 address
CNAME:        Domain alias → Another domain
MX:           Mail server priority
NS:           Authoritative nameserver
TXT:          Text information
SPF:          Email sender verification
SRV:          Service location
AAAA:         Domain name → IPv6 address
SOA:          Zone authority information
PTR:          IP address → Domain name (reverse DNS)

Advanced DNS Records

NSID:         Nameserver identifier
DNSKEY:       DNSSEC public key



⚙️ Configuration Examples

TinyDNS Record Format

.    SOA, NS, A
&    NS, A
@    MX, A
=    PTR, A
+    A
'    TXT
^    PTR
C    CNAME
Z    SOA
%    Client location condition
#    Comment
-    Disable A record
:    Custom
6    AAAA, PTR
3    AAAA


bind forwarding zone example

$TTL 1D
@       IN  SOA     ns.somaz.com. root.somaz.com. (
                        0       ; serial
                        1D      ; refresh
                        1H      ; retry
                        1W      ; expire
                        3H )    ; minimum

        IN  NS      ns.somaz.com.
        IN  A       172.17.5.10

ns      IN  A       172.17.5.10
www     IN  A       172.17.5.10

bind reverse zone example

$TTL 1D
@       IN  SOA     ns.somaz.com. root.somaz.com. (
                        0       ; serial
                        1D      ; refresh
                        1H      ; retry
                        1W      ; expire
                        3H )    ; minimum

        IN  NS      ns.somaz.com.
        IN  A       172.17.5.10

10      IN  PTR     ns.somaz.com.
10      IN  PTR     www.somaz.com.



📚 Reference