Skip to main content

How DNS Works: From Domain Name to IP Address

A clear, visual explanation of DNS resolution including recursive queries, record types, TTL caching, and common troubleshooting

Every time you type a URL into your browser, a complex yet efficient system works behind the scenes — DNS (Domain Name System). Often called “the phonebook of the internet,” DNS translates human-readable domain names (like example.com) into machine-readable IP addresses (like 93.184.216.34). This article explains exactly how DNS works, step by step.

Why DNS Exists

Every server on the internet has a unique IP address. Without DNS, you’d need to memorize IP addresses to visit websites. Imagine typing 142.250.80.46 every time you want to use Google — clearly impractical.

DNS solves this problem: you remember domain names, and DNS automatically finds the corresponding IP addresses.

The Complete DNS Resolution Process

When you type www.example.com into your browser and press Enter, here’s what happens:

1. Browser Cache Lookup

The browser first checks its own DNS cache. If you recently visited this website, the browser may already know its IP address and can use it directly.

2. Operating System Cache Lookup

If the browser cache misses, the operating system checks its DNS cache. On most systems, this is managed by a component called the “stub resolver.”

3. Recursive DNS Server Query

If local caches both miss, the request goes to a recursive DNS server (typically provided by your ISP, or a public DNS like 8.8.8.8 that you’ve manually configured). The recursive server handles the remaining queries on your behalf.

4. Root Name Servers

The recursive server first queries a root name server. There are 13 root server clusters worldwide (labeled A through M). They don’t know example.com’s IP address directly, but they know who manages .com domains.

5. TLD Name Servers

The root server directs the recursive server to the .com TLD (Top-Level Domain) server. TLD servers manage information for all .com domains and know which authoritative DNS server handles example.com.

6. Authoritative DNS Server

Finally, the recursive server queries example.com’s authoritative DNS server. This server holds the definitive DNS records for the domain and returns the IP address for www.example.com.

7. Response Delivered

The recursive server returns the IP address to your computer and caches the result. Your browser then sends an HTTP request to that IP address, and the webpage loads.

The entire process typically takes just tens of milliseconds.

DNS Record Types Explained

DNS isn’t just about domain-to-IP mapping. It supports multiple record types for different networking needs.

A Record (Address Record)

The most fundamental DNS record, mapping a domain to an IPv4 address.

example.com.    A    93.184.216.34

AAAA Record

Similar to an A record but maps to an IPv6 address. As IPv4 addresses deplete, AAAA records become increasingly important.

example.com.    AAAA    2606:2800:220:1:248:1893:25c8:1946

CNAME Record (Canonical Name)

Points one domain to another domain. Commonly used to point the www subdomain to the apex domain.

www.example.com.    CNAME    example.com.

Important: A CNAME record cannot coexist with other record types at the same name. Root domains (like example.com) should typically not use CNAME records.

MX Record (Mail Exchange)

Specifies the mail server responsible for handling email for the domain. MX records have a priority value — lower numbers mean higher priority.

example.com.    MX    10    mail1.example.com.
example.com.    MX    20    mail2.example.com.

TXT Record

Stores arbitrary text information. Common uses include:

  • SPF records: Prevent email spoofing
  • DKIM records: Email digital signature verification
  • Domain verification: Services like Google and Let’s Encrypt use TXT records to verify domain ownership
example.com.    TXT    "v=spf1 include:_spf.google.com ~all"

NS Record (Name Server)

Specifies which DNS servers are authoritative for the domain.

example.com.    NS    ns1.exampledns.com.
example.com.    NS    ns2.exampledns.com.

SOA Record (Start of Authority)

Every DNS zone has one SOA record containing administrative information such as the primary DNS server, administrator email, serial number, and various timeout settings.

TTL: The Key to DNS Caching

TTL (Time To Live) is a critical parameter in DNS records. It tells DNS resolvers how long they can cache a record.

How TTL Works

  • TTL is measured in seconds (e.g., 3600 means 1 hour)
  • When TTL expires, resolvers must re-query the authoritative DNS for fresh records
  • Lower TTL means faster change propagation but increases DNS query volume
  • Higher TTL improves caching efficiency but slows down change propagation
ScenarioRecommended TTLNotes
Normal websites3600 (1 hour)Balances caching efficiency and update speed
Pre-migration300 (5 minutes)Lower in advance for quick cutover
CDN services86400 (24 hours)CDN handles its own caching; DNS changes are rare
Mail servers3600-86400Mail servers rarely change

Server Migration TTL Strategy

When preparing for a server migration, the correct TTL strategy is:

  1. 24-48 hours before migration: Lower TTL to 300 seconds
  2. Wait for old TTL to expire: Ensure all caches have refreshed
  3. Update DNS records: Point to the new server IP
  4. After verifying migration: Restore TTL to normal values

DNS Security: DNSSEC Overview

Traditional DNS has no built-in security mechanism, making it vulnerable to DNS spoofing and cache poisoning attacks. DNSSEC (DNS Security Extensions) addresses this through digital signatures.

How DNSSEC Works

DNSSEC adds digital signatures to DNS records. When a resolver receives a DNS response, it can verify the signature to confirm:

  • The response genuinely came from the authoritative DNS server
  • The response content wasn’t tampered with during transit

Should You Enable DNSSEC?

  • Recommended: If both your registrar and DNS provider support DNSSEC
  • Caution: Misconfigured DNSSEC can make your domain completely unresolvable — worse than not using it at all

Common DNS Troubleshooting

Domain Won’t Resolve

  1. Check if the domain has expired
  2. Verify NS records point to the correct DNS provider
  3. Confirm A/CNAME records are configured properly
  4. Use the dig command to trace the resolution path step by step

Slow DNS Resolution

  1. Try switching DNS servers (e.g., Cloudflare’s 1.1.1.1 or Google’s 8.8.8.8)
  2. Check your network connection
  3. Investigate whether a firewall is blocking DNS traffic

DNS Changes Not Taking Effect

  1. Confirm changes are saved at your DNS provider
  2. Check the TTL value — you may need to wait for old caches to expire
  3. Flush your local DNS cache
  4. Use multi-region DNS propagation checkers to verify status
DNS ServerIPv4 AddressHighlights
Cloudflare1.1.1.1 / 1.0.0.1Fastest, privacy-focused
Google8.8.8.8 / 8.8.4.4Stable, global coverage
Quad99.9.9.9Built-in malicious site blocking
OpenDNS208.67.222.222Customizable filtering rules

Conclusion

DNS is one of the most critical pieces of internet infrastructure. Understanding how it works helps you manage domains and websites more effectively and troubleshoot issues quickly. Remember these core concepts: DNS resolution is a recursive query process involving root servers, TLD servers, and authoritative servers; different record types serve different networking purposes; and TTL controls DNS caching behavior — proper TTL management is essential for server migrations.