Let's Talk About Software, Hardware, DevOps and Other Fun Stuff

Published on: Mar 10, 2025
Updated on: Mar 10, 2025

How Stuff Works Part 01: DNS

A Brief Explanation of DNS

Everybody's favorite analogy is that DNS (Domain Name System) is like the internet's phone book. It's a system that translates human-readable domain names (google.com, rsmith.cloud) into IP addresses like 192.168.1.1.

When a user requests a website in their browser, say google.com, the browser first checks its local DNS cache to see if it already has a matching IP address for it. This DNS cache is what is reset when you use the command ipconfig /flushdns on Windows, and is why websites sometimes don't work before using this command, and do work after: The IP entry in the cache no longer matches the actual IP that a website has in the real world - kind of like calling a number from an old phone book, that has been disconnected (okay enough with that analogy nobody's used phone books in decades).
If there's an entry in the cache and it works, great! The website is shown immediately. If there is no entry, the browser needs to send a request to a DNS resolver to look up that website's entry. That DNS resolver can be provided by an ISP, or you can set your own provided by a company (like Google's 8.8.8.8 or Cloudflare's 1.1.1.1). That resolver also has a cache that it checks, and again, if a match is found, it immediately returns the stored IP address and the user's browser can connect to the website.

If the DNS resolver also has no cached entry, it needs to ask a Root Name Server to redirect it to the appropriate TLD (Top Level Domain) Server. The Root Name Server doesn't have any cached IP entries, it instead knows which TLD Server it needs for the incoming request. If for example the request is a .com website, it directs the request to the .com TLD Server. The TLD Server then directs the query to the Authoritative Name Server for the request, which will have the actual IP address for said request.

When you register a domain with a domain registrar, that company submits your domain's NS (Name Server) records to the TLD Server so that it knows where to look up that domain's IP address.

This IP address gets passed back to the DNS Resolver, which will likely cache it for future requests, and then back to the user's computer, where it is again cached. The website can now be displayed since the user has the correct IP address from the website's Authoritative Name Server - that is, as long as the IP entry with the Name Server is actually correct. Managing DNS records is a topic for another time.

Root Name Servers are globally distributed using Anycast, so no matter where you are, your request is routed to the nearest available Root Name Server.