DEV Community

Tyson Cung
Tyson Cung

Posted on

How DNS Actually Works — The Internet's Invisible Backbone

You type "google.com" into your browser and a webpage appears. Somewhere between your keystrokes and the pixels loading, a system you've never thought about did something extraordinary — in under 50 milliseconds.

Your Computer Is Clueless

Here's something that surprises people: your browser has no idea what "google.com" means. Computers speak IP addresses — numbers like 142.250.70.14. Domain names are a human convenience. DNS (Domain Name System) is the translation layer between what you type and where your browser actually goes.

Without DNS, you'd need to memorize IP addresses for every website. The entire internet would feel like dialing phone numbers from memory. DNS is the contacts app for the web.

The Four-Step Lookup Chain

When you hit enter on a URL, here's what actually happens:

Step 1: Browser cache. Your browser checks if it recently looked up this domain. If you visited google.com five minutes ago, it already knows the IP. Done. No network request needed.

Step 2: OS resolver. Cache miss? Your operating system has its own DNS cache. On Mac, you can see it with sudo dscacheutil -flushcache. On Linux, systemd-resolved maintains one. This catches a lot of repeat lookups across different apps.

Step 3: Recursive resolver (your ISP). Still nothing? The request goes to a recursive resolver — usually run by your ISP or a public service like Cloudflare (1.1.1.1) or Google (8.8.8.8). This server does the heavy lifting. It doesn't know the answer yet, but it knows who to ask.

Step 4: The hierarchy — root → TLD → authoritative. The recursive resolver starts at the top of the DNS tree. It asks a root server: "Where do I find .com domains?" The root server points it to the .com TLD (Top-Level Domain) server. The TLD server says: "google.com? Ask this authoritative nameserver." The authoritative server finally returns the actual IP address.

Four hops. Usually under 50ms total. You never notice.

13 Root Server Sets Run the Entire Internet

This is the fact that blows people's minds: there are only 13 root server addresses for the entire global internet. Named A through M, operated by organizations like ICANN, Verisign, NASA, and the US Army Research Lab.

"13 servers" sounds terrifyingly fragile. But each "server" is actually a cluster — over 1,700 physical instances spread across the globe using anycast routing. When your resolver contacts a root server, it reaches the geographically nearest instance automatically. The system is massively redundant.

The root servers handled over 13 billion queries per day as of recent ICANN reports. They've never all gone down simultaneously. The architecture is one of the most resilient systems humans have ever built.

DNS Caching Makes Everything Fast

The reason DNS feels instant is aggressive caching at every level. Each DNS record carries a TTL (Time To Live) — a number in seconds that says "you can trust this answer for this long."

Typical TTLs range from 300 seconds (5 minutes) for dynamic services to 86,400 seconds (24 hours) for stable domains. During that window, no additional DNS lookups happen. Your browser, your OS, and your ISP's resolver all cache independently.

This is also why DNS changes don't propagate instantly. Change your domain's IP address and some users will still hit the old one until their cached records expire. "DNS propagation" isn't really propagation — it's cache expiration rippling across millions of resolvers worldwide.

DNS Over HTTPS Changed the Privacy Game

Traditional DNS queries are sent in plain text. Your ISP can see every domain you visit — and historically, many did exactly that (sometimes selling the data). DNS over HTTPS (DoH) and DNS over TLS (DoT) encrypt these queries.

Firefox enabled DoH by default in 2020. Chrome followed. Cloudflare's 1.1.1.1 and Google's 8.8.8.8 both support encrypted DNS. It's a meaningful privacy improvement, though it shifts trust from your ISP to your DNS provider — pick one you trust.

What Breaks When DNS Breaks

The 2021 Facebook outage is the textbook example. Facebook's engineers accidentally withdrew their BGP routes, which made their DNS servers unreachable. For about six hours, facebook.com simply didn't resolve. The domain existed, the servers were running, but DNS couldn't find them. Billions of users got error pages.

Dyn (now Oracle) got DDoSed in 2016, taking out Twitter, Reddit, Netflix, and Spotify simultaneously. One DNS provider going down cascaded into a chunk of the internet becoming unreachable. It exposed how many major services relied on a single DNS provider.

The Takeaway

DNS is one of those systems that works so well you forget it exists. It resolves billions of queries per day, routes you to the right server in milliseconds, and the core architecture has been stable since the 1980s. Not many systems can claim that track record.

Next time a website loads, take a beat. Somewhere between your keyboard and that webpage, 13 root server clusters, a chain of nameservers, and decades of careful engineering just did something remarkable — and nobody noticed.

That's good infrastructure.

Top comments (0)