DEV Community

Networth Eye
Networth Eye

Posted on

DNS and IP Addresses: How the Internet Finds Your Website

Every time you type a website name into your browser and hit enter, something remarkable happens in the background — usually in well under a second. Your computer figures out exactly which server, somewhere in the world, is hosting that website, and connects to it. The system that makes this possible is built on the relationship between DNS and IP addresses, two pieces of internet infrastructure that work together so seamlessly most people never think about them at all.

This article breaks down how that relationship works, walks through what actually happens during a DNS lookup, and explains why you sometimes can't reach a website even though nothing seems wrong on your end.

The Internet's Phonebook

Think about how you used to find a friend's phone number before smartphones stored contacts for you. You didn't memorize strings of ten random digits for everyone you knew. Instead, you looked up their name in a phonebook, and the phonebook gave you the number to dial.
DNS, or the Domain Name System, plays exactly that role for the internet. Computers, servers, and routers don't actually communicate using names like "example.com." They communicate using numerical labels called IP addresses. DNS exists to translate the human-friendly names we type into browsers into the machine-friendly numbers that computers use to route traffic.

This translation is the entire reason DNS exists. Without it, using the internet would mean memorizing long strings of numbers for every single website you wanted to visit, and that's simply not how human memory works well.

IP Address Definition: What Are We Actually Translating To?

Before going further, it helps to have a clear IP address definition. An IP address (Internet Protocol address) is a unique numerical label assigned to every device connected to a network that uses the Internet Protocol for communication. It works similarly to a mailing address — it tells data where to go and where it came from.

There are two formats you'll encounter:

IPv4 addresses, which look like 192.0.2.146. These are made up of four numbers between 0 and 255, separated by periods. IPv4 has been the standard for decades, but the internet is gradually running out of available IPv4 addresses because there are only about 4.3 billion possible combinations — not nearly enough for every device on Earth.

IPv6 addresses, which look like 2001:0db8:85a3:0000:0000:8a2e:0370:7334. These are longer, alphanumeric addresses designed to solve the shortage problem, offering a vastly larger pool of possible addresses.
Every website, whether it's a personal blog or a massive e-commerce platform, is ultimately hosted on a server that has one or more IP addresses. When you visit a website, your device needs that numerical address to actually establish a connection. DNS is the mechanism that gets you there without you ever having to know or type the number yourself.

How IP Addresses Work in Practice

Understanding how IP addresses work makes the DNS lookup process much easier to follow. Every device on a network — your laptop, your phone, a web server, a router — needs an IP address to send and receive data. When your browser wants to load a webpage, it doesn't send a request to "example.com" over the wire. It sends a request to the IP address of the server hosting that site, using a set of rules (protocols) that define how data packets should be formatted, addressed, and routed.
IP addresses can be:

Static, meaning they stay the same over time. Servers hosting websites typically use static IP addresses so that DNS records pointing to them remain accurate.

Dynamic, meaning they change periodically. Most home internet connections use dynamic IP addresses assigned by your internet service provider, which is one reason your home network isn't a great place to host a permanent website without extra configuration.

This distinction matters because DNS records need to point to something stable. If a server's IP address changes without the corresponding DNS record being updated, visitors trying to reach that website will either land on the wrong server or get no response at all.

A Simplified Walkthrough of a DNS Lookup

So what actually happens between typing a web address and seeing a page load? Here's a simplified version of the process, broken into steps.
Step 1: You type a domain name into your browser. Let's say you type www.example.com and press enter. Your browser doesn't know the IP address associated with this domain yet, so it needs to find out.

Step 2: Your browser checks its cache. Before doing anything else, your browser checks whether it has recently looked up this same domain. If it has, and the cached result hasn't expired, it can skip the rest of the process entirely and use the stored IP address. This is one form of DNS caching, and it's a major reason why websites you visit frequently tend to load faster than ones you're visiting for the first time.

Step 3: The request goes to a DNS resolver. If there's no usable cached result, the request is passed to a DNS resolver — typically operated by your internet service provider, though many people configure their devices to use a public resolver instead. The resolver's job is to track down the correct IP address on your behalf.

Step 4: The resolver queries the root and TLD servers. If the resolver doesn't already have the answer cached, it starts a series of queries. First, it asks a root DNS server, which doesn't know the exact IP address but knows which server manages addresses for the domain's extension — .com, .org, .net, and so on. This is called a Top-Level Domain (TLD) server.

Step 5: The TLD server points to the authoritative name server. The TLD server responds with the address of the authoritative name server for that specific domain — the server that actually holds the DNS records for example.com.

Step 6: The authoritative name server returns the IP address. The resolver queries the authoritative name server directly, and this server returns the actual IP address associated with www.example.com.

Step 7: The IP address is returned to your browser. The resolver passes this IP address back to your browser, and typically caches it for a set period of time so future requests can skip several of these steps.

Step 8: Your browser connects to the server. With the IP address in hand, your browser opens a connection to the web server and requests the actual content of the page. The server responds, and the page begins to load.

All of this typically happens in a fraction of a second, which is part of why the system feels invisible during everyday browsing.

Why DNS Caching Matters

DNS caching deserves a closer look because it explains a lot of behavior that can otherwise seem confusing. Caching happens at multiple levels — your browser, your operating system, your router, and your ISP's DNS resolver may all store DNS results temporarily rather than looking them up fresh every time.

Each DNS record has a value called TTL, or Time to Live, which tells caching systems how long they're allowed to store that record before checking for an updated version. TTL values are typically set anywhere from a few minutes to a full day, depending on how the domain's DNS is configured.

Caching exists for a good reason: it dramatically reduces the number of lookups needed across the internet and speeds up browsing for everyone. But it also has a side effect worth understanding — when a DNS record changes, that change doesn't propagate instantly everywhere. It has to wait for old cached copies to expire.

Why a Website Might Be Temporarily Unreachable After a DNS Change

This caching behavior explains one of the more common sources of confusion for website owners and visitors alike: a site that was recently moved to a new server, or had its DNS settings updated, might be unreachable or show outdated content for a period of time afterward.
Here's why. When someone updates a DNS record — for example, pointing a domain to a new hosting provider — that change needs to spread across all the caching resolvers around the world that had the old record stored. Until each of those caches expires and refreshes, different visitors might get different results depending on which resolver they're using and how recently that resolver last checked.

This period is often referred to informally as "DNS propagation," and it's why website migrations are typically planned with some buffer time. It's not that the change failed — it's that the old information hasn't fully aged out of caches yet. Propagation delays can range from a few minutes to, in less common cases, up to 24–48 hours, depending on the TTL settings involved and how various networks handle caching.

Troubleshooting DNS-Related Connectivity Issues: A Beginner's Guide
If you've ever tried to visit a website and gotten an error like "This site can't be reached" or "DNS server not responding," the issue often traces back somewhere in the lookup chain described above. Here's a simple, beginner-friendly approach to figuring out what's going on.

  1. Try a different website. First, confirm whether the problem is specific to one site or affects your internet connection broadly. If no websites load, the issue is likely with your connection rather than DNS specifically.

  2. Restart your router. Routers cache DNS information too, and sometimes that cache becomes outdated or corrupted. A restart clears temporary data and forces fresh lookups.

  3. Flush your device's DNS cache. Your computer keeps its own local DNS cache, and occasionally it holds onto an outdated or incorrect record. Flushing this cache forces your device to perform a fresh lookup rather than relying on stored information. Both Windows and macOS have built-in commands for this, accessible through their respective command-line tools.

  4. Try a different DNS resolver. If your default DNS resolver (usually provided by your ISP) is experiencing problems, switching to a public resolver can often resolve the issue. This is typically done in your device's or router's network settings.

  5. Check if the problem is on the website's end. Sometimes the issue isn't with your device at all — the website's DNS records might be misconfigured, or the site might be in the middle of a migration. If a site is unreachable for you but works fine for others, or vice versa, propagation delays or resolver-specific caching are often the culprit.

  6. Use online DNS lookup tools. Various free online tools let you check what IP address a domain currently resolves to, from multiple locations around the world. If these tools show a different IP address than you expect, it usually points to a DNS configuration issue on the website's side rather than a problem with your own connection.

Most everyday DNS issues resolve themselves within a short window, either because a cache expires or because a temporary hiccup on the resolver's end clears up.

Seeing the Endpoint DNS Resolves To

Everything described in this article ends with the same result: a domain name gets translated into an IP address, and that address is the actual destination your connection is routed to. It can be genuinely useful to see this in action for yourself, particularly if you're troubleshooting a connection issue, setting up a website, or just curious about the infrastructure behind your everyday browsing.

If you want to try an IP address lookup, you can see the public IP address your own device is currently using to connect to the internet — the same type of numerical address that DNS is working behind the scenes to resolve every time you visit a website. It's a small but concrete way to see the endpoint that all those DNS lookups are ultimately pointing toward.

Understanding DNS and IP addresses doesn't require becoming a network engineer. But knowing that a phonebook-like system is quietly translating names into numbers every time you browse — and knowing roughly how that system works — makes the internet feel a little less like magic and a little more like the elegant piece of engineering it actually is.

Top comments (0)