Purpose of DNS – Domain Name System Explained
1. What Is DNS?
DNS (Domain Name System) is the internet's distributed naming system — a global
database that translates human-readable domain names (like google.com) into
machine-readable IP addresses (like 142.250.190.46) that computers use to
route traffic across the internet.
Without DNS, you would have to memorise a unique numeric IP address for every website, email server, and internet service you use. DNS makes the internet usable for humans by creating a consistent, globally accessible layer of naming on top of the underlying numeric addressing system.
Without DNS: With DNS:
To visit Google, type: To visit Google, type:
142.250.190.46 google.com
(or 2a00:1450:4009:82c::200e) ↓ DNS resolves it
Hard to remember ❌ 142.250.190.46 ✅
Related pages: How DNS Works (Full Resolution Process) | DNS Record Types | Forward & Reverse DNS Lookup | dig Command | nslookup Command
2. Why the Internet Needs DNS
DNS solves several fundamental problems that would make the internet unworkable without it:
| Problem Without DNS | How DNS Solves It |
|---|---|
| Humans cannot reliably memorise numeric IP addresses (e.g., 172.217.3.110) | DNS maps memorable names (google.com) to IPs — users never need to know the number |
| IP addresses can change when servers migrate to new hardware or cloud providers | The domain name stays constant — only the DNS record needs updating, invisibly to users |
| A single server cannot handle global traffic reliably | DNS enables load balancing — one domain can map to dozens of IPs distributed worldwide |
| Different services (web, email, FTP) on the same domain need separate routing | Different DNS record types (A, MX, CNAME) route each service to the right server |
| Centralising all name records in one database would not scale globally | DNS is distributed and hierarchical — billions of queries handled through delegation |
| Repeatedly looking up the same domain wastes bandwidth and adds latency | DNS caching stores recent answers for their TTL duration — dramatically reducing lookups |
3. The DNS Hierarchy — How It Is Structured
DNS is organised as an inverted tree with the root zone at the top. Every domain name is read right-to-left through the hierarchy — from the most general (root) to the most specific (hostname).
. (root)
│
┌───────────┼───────────┐
.com .org .uk ← Top-Level Domains (TLDs)
│
┌──────┼──────┐
google example cisco ← Second-Level Domains
│
┌───┼────┐
www mail api ← Subdomains (hostnames)
Full name: www.google.com.
Read right-to-left: root(.) → com → google → www
Domain Name Anatomy
| Part | Example | Description |
|---|---|---|
| Root label | . (trailing dot) |
The invisible root of all domain names. Technically every FQDN ends with a dot
(e.g., www.example.com.) — usually omitted in everyday use |
| Top-Level Domain (TLD) | com, org, uk |
Generic TLDs (gTLD: .com, .net, .org) or country codes (ccTLD: .uk, .de, .jp). Managed by ICANN-accredited registries |
| Second-Level Domain (SLD) | example in example.com |
The name registered by the domain owner with a registrar |
| Subdomain | www, mail, api |
Created by the domain owner in their DNS zone — unlimited nesting allowed |
| FQDN | www.example.com. |
Fully Qualified Domain Name — the complete unambiguous name including all labels |
4. Types of DNS Servers — Their Roles
| Server Type | Role | Location in Hierarchy | Examples |
|---|---|---|---|
| Root Nameserver | Answers queries about TLD server locations. Does not know specific domain IPs — only knows which servers handle each TLD | Top of hierarchy | 13 root server clusters: a.root-servers.net through m.root-servers.net (actually hundreds of anycast nodes globally) |
| TLD Nameserver | Manages a top-level domain — knows which authoritative servers handle each registered domain within the TLD | Second level | Verisign runs .com/.net TLDs (a.gtld-servers.net). Nominet runs .uk |
| Authoritative Nameserver | Holds the actual DNS zone records — the definitive source for a domain's A, MX, CNAME, TXT records etc. Returns the aa (authoritative answer) flag | Bottom of hierarchy | ns1.example.com, Cloudflare DNS, AWS Route 53, GoDaddy nameservers |
| Recursive Resolver | The "workhorse" — receives client queries, walks the entire hierarchy (root → TLD → authoritative) on the client's behalf, caches results | Between client and hierarchy | 8.8.8.8 (Google), 1.1.1.1 (Cloudflare), 9.9.9.9 (Quad9), ISP DNS |
| Forwarding Resolver | Passes all queries upstream to another resolver rather than doing its own recursive resolution. Common in home routers and corporate networks | Between client and recursive resolver | Home router at 192.168.1.1 forwarding to 8.8.8.8 |
5. How DNS Works — Complete Step-by-Step Resolution
Every time a device needs to connect to a hostname it hasn't recently looked up, the following sequence occurs. Modern systems are optimised to short-circuit this at the earliest cache hit — only uncached, fresh queries go all the way to the authoritative server.
User types: www.example.com
┌─────────────────────────────────────────────────────────────┐
│ 1. OS checks local hosts file │
│ /etc/hosts (Linux/Mac) or │
│ C:\Windows\System32\drivers\etc\hosts (Windows) │
│ → Match? Use it immediately. Done. │
└──────────────────────┬──────────────────────────────────────┘
│ No match
┌──────────────────────▼──────────────────────────────────────┐
│ 2. OS checks local DNS resolver cache │
│ Previous lookup still within TTL? Use cached IP. Done. │
└──────────────────────┬──────────────────────────────────────┘
│ Cache miss / expired
┌──────────────────────▼──────────────────────────────────────┐
│ 3. Query sent to Recursive Resolver (e.g., 8.8.8.8) │
│ Resolver checks its own cache first │
│ Cache hit? Return immediately to client. Done. │
└──────────────────────┬──────────────────────────────────────┘
│ Resolver cache miss
┌──────────────────────▼──────────────────────────────────────┐
│ 4. Resolver queries a Root Server │
│ "Who handles .com?" │
│ Root returns: a.gtld-servers.net (the .com TLD server) │
└──────────────────────┬──────────────────────────────────────┘
│
┌──────────────────────▼──────────────────────────────────────┐
│ 5. Resolver queries the .com TLD Server │
│ "Who handles example.com?" │
│ TLD returns: ns1.example.com (authoritative NS) │
└──────────────────────┬──────────────────────────────────────┘
│
┌──────────────────────▼──────────────────────────────────────┐
│ 6. Resolver queries ns1.example.com (Authoritative Server) │
│ "What is the A record for www.example.com?" │
│ Authoritative returns: 93.184.216.34 (aa flag set) │
└──────────────────────┬──────────────────────────────────────┘
│
┌──────────────────────▼──────────────────────────────────────┐
│ 7. Resolver caches answer for TTL seconds │
│ Returns 93.184.216.34 to client │
│ Client OS caches it │
│ Browser connects to 93.184.216.34:443 (HTTPS) │
└─────────────────────────────────────────────────────────────┘
Total time: typically 20–100ms for uncached queries,
under 1ms for cached responses
6. DNS Record Types — Complete Reference
| Record | Full Name | Purpose | Example |
|---|---|---|---|
| A | Address | Maps hostname to IPv4 address — the most fundamental record type | example.com. A 93.184.216.34 |
| AAAA | IPv6 Address | Maps hostname to IPv6 address — the 128-bit equivalent of A records | example.com. AAAA 2606:2800:220:1:248:1893:25c8:1946 |
| CNAME | Canonical Name | Creates an alias — maps one hostname to another hostname (not IP directly) | www.example.com. CNAME example.com. |
| MX | Mail Exchange | Specifies mail servers for a domain with priority values (lower = preferred) | example.com. MX 10 mail.example.com. |
| TXT | Text | Arbitrary text — used for SPF (sender policy), DKIM (email signing), DMARC, domain ownership verification | example.com. TXT "v=spf1 include:_spf.google.com ~all" |
| NS | Name Server | Specifies which authoritative nameservers hold the DNS zone for this domain | example.com. NS ns1.example.com. |
| PTR | Pointer | Reverse DNS — maps an IP address back to a hostname (used for email, logging) | 34.216.184.93.in-addr.arpa. PTR example.com. |
| SOA | Start of Authority | Zone metadata — primary NS, admin email, serial number, refresh/retry/expire timers | example.com. SOA ns1.example.com. admin.example.com. 2024041544 7200 3600 1209600 3600 |
| SRV | Service Locator | Locates services (SIP, XMPP, Microsoft AD) by protocol and port number | _sip._tcp.example.com. SRV 10 20 5060 sip.example.com. |
| CAA | Certification Authority Authorisation | Restricts which Certificate Authorities can issue SSL certificates for the domain | example.com. CAA 0 issue "letsencrypt.org" |
7. DNS Caching — Why It Matters
Every DNS answer includes a TTL (Time To Live) value in seconds. Resolvers and client operating systems cache the answer for the duration of the TTL before querying again. Caching is fundamental to DNS scalability — without it, every single web request would require 3+ lookups across multiple servers worldwide.
! dig shows TTL in the ANSWER section:
$ dig google.com
;; ANSWER SECTION:
google.com. 52 IN A 142.250.190.46
↑
TTL = 52 seconds remaining until this cache entry expires
(Google uses 60-second TTL for load balancing flexibility)
Levels of DNS Caching
| Cache Location | Who Controls It | How to Clear |
|---|---|---|
| Browser DNS cache | Browser itself (Chrome, Firefox keep their own cache) | Chrome: chrome://net-internals/#dns → Clear host cache |
| OS resolver cache | Operating system | Windows: ipconfig /flushdns | Linux: sudo systemd-resolve --flush-caches
| macOS: sudo dscacheutil -flushcache |
| Recursive resolver cache | ISP / public DNS provider (8.8.8.8, 1.1.1.1) | Cannot flush externally — must wait for TTL to expire |
| Authoritative server cache | Domain owner / DNS hosting provider | Update the record — cached copies expire when TTL expires |
8. Real-World DNS Examples
Example 1 — Browsing a Website
https://www.netflix.com in a browser:
- OS queries resolver → resolver walks DNS hierarchy
- Authoritative server returns:
www.netflix.com CNAME www.netflix.com.edgesuite.net. - Resolver follows CNAME to Akamai CDN → returns closest edge server IP
- Browser connects to nearest Netflix CDN node — video streams from geographically close infrastructure
Example 2 — Sending Email
- Your mail server asks DNS: "What are the MX records for gmail.com?"
- DNS returns five MX records with priorities:
gmail.com. IN MX 5 gmail-smtp-in.l.google.com. gmail.com. IN MX 10 alt1.gmail-smtp-in.l.google.com. gmail.com. IN MX 20 alt2.gmail-smtp-in.l.google.com. gmail.com. IN MX 30 alt3.gmail-smtp-in.l.google.com. gmail.com. IN MX 40 alt4.gmail-smtp-in.l.google.com.
- Your mail server connects to priority 5 server first (lowest = highest preference)
- If that server is unavailable, it falls back to priority 10, then 20, etc.
Example 3 — Internal Corporate DNS
corp.local:
sharepoint.corp.local. A 192.168.10.50 hr-portal.corp.local. A 192.168.10.60 mail.corp.local. A 192.168.10.70 printers.corp.local. A 192.168.10.80Employees access internal resources by name (sharepoint.corp.local) instead of IP. The corporate DNS server handles .corp.local queries locally and forwards all other queries to a public resolver (8.8.8.8) for internet names.
9. DNSSEC — DNS Security Extensions
DNSSEC (DNS Security Extensions) adds cryptographic signatures to DNS records, allowing resolvers to verify that responses are authentic and have not been tampered with in transit. It protects against DNS cache poisoning attacks.
The Problem DNSSEC Solves — Cache Poisoning
In a DNS cache poisoning attack, an attacker injects a forged DNS response into a resolver's cache before the legitimate response arrives. The resolver caches the attacker's IP for the domain — redirecting all queries to a malicious server (phishing site, man-in-the-middle) for the duration of the TTL.
Without DNSSEC (cache poisoning attack): Client → Resolver → [attacker intercepts] Attacker sends forged: "bank.com = 198.51.100.1" (malicious IP) Resolver caches the fake IP → All clients redirected to phishing site With DNSSEC (protected): bank.com's DNS records are signed with a private key Resolver verifies signature using the published public key (DNSKEY record) If signature invalid → query rejected → client not redirected If signature valid → ad (Authenticated Data) flag set in response
DNSSEC Components
| Record Type | Purpose |
|---|---|
DNSKEY |
Published public key used to verify signatures |
RRSIG |
Cryptographic signature over each DNS record set |
DS |
Delegation Signer — links parent zone (TLD) to child zone's DNSKEY |
NSEC/NSEC3 |
Authenticated denial of existence — proves a record does not exist (prevents zone enumeration) |
10. DNS vs. DHCP — Key Differences
DNS and DHCP are both fundamental infrastructure protocols but serve completely different purposes. They are often confused because both are configured on the same router or server in small networks.
| Feature | DNS | DHCP |
|---|---|---|
| Primary purpose | Translates domain names to IP addresses (name resolution) | Assigns IP addresses and network configuration to devices (address management) |
| Transport & ports | UDP/TCP port 53 | UDP port 67 (server), port 68 (client) |
| Protocol standard | RFC 1034/1035 (and many extensions) | RFC 2131 |
| What it gives a client | IP address for a hostname (e.g., google.com → 142.250.190.46) | The client's own IP address, subnet mask, default gateway, and DNS server IPs |
| Direction of query | Name → IP (and IP → Name for reverse DNS) | Client broadcasts, server assigns from a pool |
| Scope | Global — resolves names across the entire internet | Local — assigns addresses within a subnet |
| Relationship | DHCP delivers the DNS server address to clients (DHCP Option 6) | DHCP relies on DNS for clients to use network services by name — see DHCP Server Configuration |
| Typical example | Resolving youtube.com → IP |
Your laptop being assigned 192.168.1.15 when it joins a network |
11. Why DNS Is Critical Infrastructure
DNS is one of the most critical pieces of internet infrastructure — a global DNS outage would effectively take the internet offline for most users (even if all servers remained running). Several properties make DNS uniquely important:
- Universal dependency: Nearly every internet connection — web browsing, email, APIs, streaming, cloud services, IoT — starts with a DNS lookup. Services that are "up" become unreachable if DNS fails.
- Massive scale: The DNS system processes over a trillion queries per day globally. Google Public DNS alone handles over 400 billion queries daily. This scale is managed through the distributed, cached, hierarchical architecture.
- High availability by design: Every domain must have at least two authoritative nameservers (primary and secondary). The 13 root server clusters each have hundreds of anycast instances. There is no single point of failure in a properly configured DNS system.
- Flexibility and abstraction: DNS decouples domain names from IP addresses. Entire data centre migrations, cloud provider changes, CDN updates, and load balancing changes can happen invisibly to users by simply updating DNS records.
- Security enforcement point: DNS is increasingly used as a security control — DNS-based threat intelligence can block malicious domains, C2 servers, and phishing sites at the network level before any connection is established. This complements ACLs and firewall rules for layered defence.
12. Common DNS Issues and Troubleshooting
For a broader network connectivity diagnostic workflow that includes DNS checks, see Troubleshooting Connectivity.
| Problem | Likely Cause | Diagnostic Command & Fix |
|---|---|---|
| Website not loading — "can't find server" | DNS resolution failing: resolver unreachable, wrong DNS server configured, or domain issue | nslookup example.com — check if it resolves. Try
nslookup example.com 8.8.8.8 — if this works, your configured
DNS server is the problem |
| Website loads for some users but not others | DNS propagation delay — different resolvers still have the old cached IP | Compare: dig @8.8.8.8 example.com vs
dig @1.1.1.1 example.com. Wait for TTL to expire globally. |
| Slow DNS resolution (pages feel sluggish) | High-latency DNS resolver (e.g., distant ISP DNS server) | Switch to faster public resolver: 8.8.8.8 (Google) or
1.1.1.1 (Cloudflare — typically fastest). Test with:
dig example.com +stats (check query time) |
| Old IP still being returned after DNS change | Stale TTL cache in resolver or local OS | Windows: ipconfig /flushdns | Linux:
sudo systemd-resolve --flush-caches. External resolvers: wait
for TTL to expire |
| Emails bouncing or going to spam | Missing or mismatched PTR record, missing SPF/DKIM TXT records | dig -x <mail-server-IP> (check PTR exists),
dig example.com TXT (check SPF/DKIM records) |
| DNS cache poisoning suspected | Resolver returning unexpected IPs for known domains | Compare dig @8.8.8.8 domain.com against your resolver result.
Enable DNSSEC on your resolver. Use encrypted DNS (DoH/DoT) |
| SERVFAIL returned for a domain | Authoritative server unreachable, DNSSEC validation failure, or lame delegation | dig example.com +trace — follow the delegation chain to find
where it fails |
Quick Troubleshooting Commands
! Basic DNS resolution test nslookup example.com ! Windows/Linux/macOS dig example.com ! Linux/macOS — full detailed output ! Test with a specific DNS server (bypass your configured resolver) nslookup example.com 8.8.8.8 dig @8.8.8.8 example.com ! Check current DNS configuration ipconfig /all ! Windows — shows DNS servers cat /etc/resolv.conf ! Linux — shows configured DNS servers ! Flush DNS cache ipconfig /flushdns ! Windows sudo systemd-resolve --flush-caches ! Linux (systemd) sudo dscacheutil -flushcache ! macOS ! Trace full DNS resolution path dig example.com +trace ! Follows root → TLD → authoritative ! Quick IP lookup (script-friendly) dig example.com +short
13. Common Misconceptions About DNS
-
"DNS is only used for website browsing."
DNS is used for every internet communication involving a hostname — email delivery (MX record lookup), API calls, cloud services, VoIP (SRV records), streaming services, IoT devices, and internal corporate resources. The internet would be nearly unusable without DNS, not just for web browsing. -
"Changing a DNS record takes effect immediately."
DNS changes take effect immediately on the authoritative server, but resolvers worldwide cache the old answer for its TTL duration. If a record has a 24-hour TTL, some users worldwide will see the old IP for up to 24 hours. Pre-lower TTL before planned changes to minimise this window. -
"There are only 13 DNS root servers."
There are 13 root server addresses (labeled a through m), but each is served by many physical servers distributed globally via anycast routing. As of 2025, there are over 1,500 root server instances worldwide. The "13 servers" is a simplification based on the original IPv4 constraint of fitting all root NS records in a single 512-byte UDP response. -
"DNSSEC encrypts DNS traffic."
DNSSEC provides authentication and integrity — it proves responses haven't been tampered with using cryptographic signatures. It does not encrypt queries or responses — your ISP and network observers can still see what domains you query. DNS-over-HTTPS (DoH) and DNS-over-TLS (DoT) provide actual encryption. -
"Flushing your local DNS cache fixes all DNS issues."
Flushing your local OS cache only affects your machine. If a recursive resolver (8.8.8.8, ISP DNS) has cached a stale entry, it continues to return the old answer to all its clients until the TTL expires — you have no control over external resolver caches.
14. Key Points & Exam Tips
- DNS = Domain Name System — translates domain names to IP addresses and vice versa. Called the "phonebook of the internet."
- DNS uses UDP port 53 (queries) and TCP port 53 (large responses, zone transfers).
- DNS hierarchy: Root (.) → TLD (.com) → Authoritative (ns1.example.com). Always root first.
- Recursive resolver (8.8.8.8): fetches DNS on client's behalf, caches results. Authoritative server: holds the official zone records, returns aa flag.
- Key record types: A (name→IPv4), AAAA (name→IPv6), MX (mail servers), CNAME (alias), TXT (SPF/DKIM), PTR (IP→name), NS (nameservers), SOA (zone metadata).
- TTL: how long resolvers cache a DNS answer. Low TTL = fast changes but more queries. High TTL = efficient but slow propagation.
- Resolution order: hosts file → local cache → recursive resolver → root → TLD → authoritative.
- DNSSEC: adds cryptographic signatures to DNS records to prevent cache poisoning. Does NOT encrypt traffic — use DoH/DoT for encryption.
- DNS ≠ DHCP: DNS resolves names to IPs; DHCP assigns IPs to devices. DHCP delivers the DNS server IP to clients via Option 6.
- Troubleshooting:
nslookup/digfor resolution testing;ipconfig /flushdns(Windows) to clear local cache;dig +traceto follow the full delegation path.
Related pages: How DNS Works | DNS Record Types | Forward & Reverse DNS Lookup | dig Command | nslookup Command