The Internet's Phone Book
Humans remember names, not numbers. You type google.com into your browser, not 172.217.14.99. But computers need IP addresses to communicate. DNS (Domain Name System) is the protocol that translates human-readable domain names into IP addresses.
Without DNS, you'd have to memorize the IP address of every website you visit. DNS makes the internet usable.
How DNS Works
DNS is a distributed database spread across thousands of servers worldwide. When you type a domain name, here's what happens:
1. Your browser checks its local cache
β (not found)
2. Your OS checks its DNS cache
β (not found)
3. Your router checks its cache
β (not found)
4. Your ISP's DNS resolver is queried
β (not found)
5. Root DNS servers are queried
β (returns referral to .com servers)
6. .com TLD servers are queried
β (returns referral to google.com's servers)
7. Google's authoritative DNS server is queried
β (returns IP: 172.217.14.99)
8. Your browser connects to 172.217.14.99
This entire process typically takes less than 100 milliseconds.
DNS Hierarchy
ββββββββββββββββ
β Root (.) β
ββββββββ¬ββββββββ
ββββββββββββββββΌβββββββββββββββ
ββββββ΄βββββ ββββββ΄βββββ ββββββ΄βββββ
β .com β β .org β β .net β
ββββββ¬βββββ ββββββ¬βββββ ββββββ¬βββββ
ββββββ΄βββββ ββββββ΄βββββ ββββββ΄βββββ
google.com amazon.com wikipedia.org
DNS is hierarchical. The root servers point to TLD (Top-Level Domain) servers (.com, .org, .net), which point to authoritative name servers for specific domains (google.com, wikipedia.org).
DNS Record Types
Type β Purpose β Example
ββββββΌβββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββ
A β Maps domain to IPv4 address β google.com β 172.217.14.99
AAAA β Maps domain to IPv6 address β google.com β 2607:f8b0:...
CNAMEβ Alias pointing to another name β www.google.com β google.com
MX β Mail server for the domain β google.com β mail.google.com
NS β Authoritative name server β google.com β ns1.google.com
TXT β Text information (SPF, DKIM) β "v=spf1 include:..."
SOA β Start of Authority (zone info) β Zone metadata
PTR β Reverse lookup (IP β domain) β 99.14.217.172 β google.com
DNS Caching
DNS results are cached at multiple levels to reduce lookup times and load on DNS servers:
- Browser cache β Your browser remembers recent lookups.
- OS cache β Your operating system caches DNS results.
- Router cache β Your home router caches results for all devices on your network.
- ISP resolver cache β Your ISP's DNS server caches results for all its customers.
Each cache entry has a TTL (Time To Live) β the number of seconds the entry is valid. After the TTL expires, the entry is discarded and a fresh lookup is performed.