What is DNS and how does it work?

What is DNS and how does it work?

Typing an address into your browser feels like magic: you type google.com, press Enter, and within a second the page appears on screen. Behind that action, however, there is a silent, multi-step process coordinated by one of the most important, and least known, systems on the internet: DNS, short for Domain Name System. Understanding what it is and how it works is not just technical curiosity; it also lets you diagnose connection errors, choose better network settings, and use tools such as flushing the DNS cache when something goes wrong.

What is DNS and what is it for?

DNS is, in essence, the phone book of the internet. People remember names such as google.com, youtube.com or wikipedia.org; machines, on the other hand, identify each other with numeric addresses called IP addresses. An IPv4 address is a number like 142.250.190.46, and an IPv6 address is a much longer string, such as 2607:f8b0:4005:800::200e. Memorizing that kind of data for every site we visit would be impossible.

The job of DNS is to translate a domain name that humans can read into the IP address a device needs to establish a connection. When you type a URL, your computer asks the name system which IP address that domain belongs to and, thanks to the answer, the browser can connect to the correct server. This translation happens every time a domain is used: while browsing, when sending email, or from mobile apps. Without DNS, the internet as we know it, with billions of sites reachable through a simple name, simply would not exist.

Why does DNS exist? The problem with IP addresses

To understand why DNS exists, look at the problem it solves. The internet is a network of millions of servers, and each one has at least one unique IP address. Connecting directly by IP has three major drawbacks:

  • IP addresses are hard to remember. Keeping a list of dozens of numbers in your head is not practical for people, and the number of services grows every day.
  • IP addresses change. A company can move its site to another server or provider and get a brand-new address; users should never have to notice or depend on that detail.
  • The system would not scale. Making every computer on Earth keep an up-to-date list of all existing domains would be unworkable; that is why the system is distributed across a global hierarchy.

To solve these problems, domain names are organized hierarchically. In google.com, the final dot represents the root, .com is the top-level domain (TLD), google is the second-level domain, and www or mail would be optional subdomains. This hierarchy means the name database does not live in a single place: each level of the tree knows who to ask for the next level, and no single organization controls the whole system.

How a DNS lookup works, step by step

When the browser needs to resolve a domain, the query travels through several players until it gets the address. A typical lookup works like this:

  1. The browser and the operating system first check their local caches: if they already know the answer and the record time-to-live (TTL) has not expired, they use it directly and the process ends here, in milliseconds.
  2. If there is no local answer, the request goes to a recursive resolver, a specialized DNS server, usually your internet service provider's (ISP) or whichever public DNS you have configured.
  3. The resolver asks a root server: it does not know google.com, but it does know which servers manage the .com top-level domain.
  4. The resolver then queries a .com TLD server, which answers by pointing to the authoritative name servers for the google.com domain.
  5. The resolver reaches the domain's authoritative server, which holds the definitive answer: the record that maps google.com to its IP address.
  6. The address travels back to your device, which stores it in cache for the TTL so it does not repeat the whole trip, and the browser opens a direct connection to the server.

This whole journey, which sounds long, normally completes in tens of milliseconds: every level keeps its own cached answers, and the resolver does not start from scratch on each query.

What is a DNS server? Public DNS servers

A DNS server is simply a computer running specialized software that answers name-resolution queries. It helps to distinguish two roles. Authoritative servers belong to a domain's owner and hold the official records for it: when someone asks about that domain, they answer with authority. Recursive resolvers, in contrast, do the fieldwork: they walk the root and TLD servers on the user's behalf until they find the answer, as described in the previous section.

By default, your computer almost always uses the resolver your ISP hands out with the connection, usually configured automatically by the router. Those servers normally work fine, but they are not always the fastest or most reliable, and sometimes they fail or get overloaded. That is why public DNS servers exist: free and open to anyone. The best-known examples are:

  • Google Public DNS: 8.8.8.8 and 8.8.4.4.
  • Cloudflare: 1.1.1.1 and 1.0.0.1, with an emphasis on speed and privacy.
  • Quad9: 9.9.9.9, which also blocks domains known to distribute malware.

Changing DNS servers is a configuration change, not a rewiring job: on Windows you do it in the IPv4 properties of your network adapter, and you can also set it on the router itself so every device at home uses it. Many users notice faster page loads and fewer resolution errors after switching to a public DNS.

The most common DNS record types

A domain's information is stored on the authoritative server as records of different types. Each type answers a different question: what is the site's IP, where should email be delivered, and so on. The most common ones are:

TypeWhat it doesExample use
AMaps a name to an IPv4 address.google.com points to 142.250.190.46
AAAAMaps a name to an IPv6 address.google.com points to 2607:f8b0:4005:800::200e
CNAMECreates an alias pointing to another domain name.www.yourdomain.com redirects to yourdomain.com
MXIndicates the domain's mail server and its priority.mail is handled by mail.provider.com
TXTStores free text; used for ownership verification, SPF and DKIM.v=spf1 include:provider.com ~all
NSPoints to the domain's authoritative servers.ns1.hostingprovider.com

Other types exist, such as SOA, PTR or SRV, but A, AAAA, CNAME, MX, TXT and NS cover the vast majority of everyday cases, from opening a website to configuring a company's email.

What does flushing the DNS mean?

As you saw, every DNS answer is cached for a period called TTL. That cache makes browsing faster, but it can also become stale: if a site changes servers and your computer keeps the old IP, you will keep seeing errors even though the site works for everyone else. In those cases, flushing the DNS helps: it clears the local resolution cache so the next lookup starts fresh.

On Windows it is very simple: open Command Prompt (CMD) or PowerShell and run the command ipconfig /flushdns. You will see the message Successfully flushed the DNS Resolver Cache, and from that moment the next lookup is resolved from scratch. On macOS you can use commands such as sudo dscacheutil -flushcache. The operation is harmless: it deletes no files or passwords, only temporary data that rebuilds itself.

Flushing the DNS cache makes sense in specific situations:

  • You changed hosting providers or a site moved to another IP and you still see the old content or connection errors.
  • You just registered or transferred a domain and lookups fail or point to a previous server.
  • You modified the DNS servers on your computer or router and want to rule out stored answers.
  • A page will not load on your computer but works on your phone over a different network: that usually points to a stale or corrupted local cache.
  • Resolution errors appear after internet outages or network changes, for example when switching from Wi-Fi to mobile data or between Wi-Fi networks.

Common DNS errors and how to fix them

DNS problems show up as cryptic messages that, in practice, usually mean one of a few things. The most frequent ones are:

  • ERR_NAME_NOT_RESOLVED (Chrome) or Server not found: the name could not be resolved by any DNS server.
  • DNS_PROBE_FINISHED_NXDOMAIN: the queried domain does not exist or is misspelled, since NXDOMAIN means non-existent domain.
  • The DNS server isn't responding (Windows): the configured resolver did not answer or is unreachable.
  • Server IP address could not be found: a resolution failure with causes similar to the ones above.

For any of these, work through the fixes in order:

  1. Check the URL. A typo is the most common cause of NXDOMAIN; if the domain belongs to you or your company, also confirm that it has not expired.
  2. Try another device and another network. If the site loads on your phone over mobile data, the problem is local: cache, router or ISP DNS.
  3. Flush the DNS cache with the command ipconfig /flushdns, as explained earlier, and try again.
  4. Switch to a public DNS such as 8.8.8.8 or 1.1.1.1 on the adapter or the router; if the error disappears, your ISP's DNS was the culprit.
  5. Restart the router and the computer. A router with a corrupted or stuck resolution table causes intermittent failures that a reboot usually fixes.
  6. Check resolution with query tools such as nslookup (built into Windows) or dig (Linux and macOS) to see what the DNS server actually answers and whether the record points where it should.
  7. If you manage the domain, allow for propagation. After changing records or NS servers, the new information takes time to reach the whole internet: generally from a few hours up to 72, depending on the configured TTL.

DNS works silently every time you open a page, send an email or use an app, and understanding its pieces turns a confusing error message into a clear diagnosis. Knowing the public servers, the most common records and commands like ipconfig /flushdns gives you the power to solve a large share of everyday connection problems yourself.

Chatea por WhatsApp