What Is DNS and How Does It Work? (Plus How to Change It)

You type example.com, press Enter, and a page appears. But computers do not route traffic by names — they use IP addresses. The system that quietly translates one into the other, thousands of times a day, is DNS (the Domain Name System). When it is slow, broken or filtered, "the internet is down" even though your connection is fine. This guide explains how DNS works, which public DNS servers exist, and how to change yours.

What DNS does

DNS is the internet's phone book. It maps a human-friendly name such as example.com to the numeric address a server actually has, such as 203.0.113.10 (an IPv4 address from the range reserved for documentation) or an IPv6 address. Without it you would have to remember a number for every site you visit — and the number can change when a site moves hosting.

How a lookup works, step by step

  1. Browser cache. The browser first checks if it already knows the answer.
  2. Operating system cache. If not, it asks the OS, which keeps its own cache.
  3. Recursive resolver. Still unknown? The request goes to the DNS server your device is configured to use — usually your ISP's, or a public one such as 8.8.8.8.
  4. Root server. If the resolver does not know either, it asks a root server, which points it to the servers for the right top-level domain (.com, .ir, ...).
  5. TLD server. The TLD server points to the domain's own authoritative name servers.
  6. Authoritative server. It gives the final answer: the IP address.
  7. Caching. Every step along the way stores the answer for a number of seconds called the TTL (time to live), so the next lookup is almost instant.

Common DNS record types

RecordWhat it holds
AAn IPv4 address for a name
AAAAAn IPv6 address for a name
CNAMEAn alias that points one name to another name
MXThe mail servers that accept email for the domain
TXTFree text, used for domain verification and email security (SPF, DKIM)
NSThe authoritative name servers for the domain

Why your choice of DNS server matters

  • Speed. A slow or overloaded resolver delays the start of every page load, even though the actual download is fast. See also how to reduce lag.
  • Reliability. If your ISP's resolver fails, sites stop loading while the connection itself is up. Switching resolver often fixes it instantly.
  • Privacy. The resolver sees every domain you look up. Traditional DNS is unencrypted; DNS over HTTPS (DoH) and DNS over TLS (DoT) encrypt these queries so the network cannot read them.
  • Filtering. Some resolvers block malware or adult domains; some networks interfere with DNS answers. Availability and behaviour of any resolver varies from country to country.

Popular public DNS resolvers

ProviderIPv4 addressesPrivate DNS hostname
Google Public DNS8.8.8.8, 8.8.4.4dns.google
Cloudflare1.1.1.1, 1.0.0.1one.one.one.one
Quad9 (blocks known malicious domains)9.9.9.9, 149.112.112.112dns.quad9.net
OpenDNS208.67.222.222, 208.67.220.220—

Which one is fastest depends on where you are and which ISP you use, so it is worth trying two or three and comparing.

How to change your DNS server

Windows 11

Settings → Network & internet → Wi-Fi (or Ethernet) → your network's properties → DNS server assignment → Edit → Manual → turn on IPv4 and enter a preferred and alternate server.

Android 9 and newer

Settings → Network & internet → Private DNS → "Private DNS provider hostname" and enter a hostname such as dns.google. (Menu names vary slightly between manufacturers.)

iPhone

Settings → Wi-Fi → tap the (i) next to your network → Configure DNS → Manual → add the server addresses.

On the router

Changing the DNS in your router's settings (see how to log in to your router) applies it to every device on the network at once.

Useful DNS commands

nslookup example.com          # ask your resolver for an address (Windows/macOS/Linux)
ipconfig /all                 # Windows: shows which DNS servers you use
ipconfig /flushdns            # Windows: clear the DNS cache
resolvectl flush-caches       # Linux (systemd-resolved): clear the cache
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder    # macOS: clear the cache

Common DNS errors

  • DNS_PROBE_FINISHED_NXDOMAIN / "server IP address could not be found": the name did not resolve — a typo, an expired domain, or a failing resolver. Try another DNS server.
  • Some sites work, some do not: often a stale cache; flush it as shown above.
  • Everything fails but pinging 8.8.8.8 works: the connection is fine and DNS is the problem. The ping and traceroute guide shows how to separate the two.

Key takeaways

  • DNS translates domain names into IP addresses, and caches answers to stay fast.
  • Your resolver affects speed, reliability and privacy, and it is easy to change on any device or at the router.
  • DoH/DoT encrypt DNS queries; ordinary DNS is readable by the network.
  • If sites will not load but you can reach an IP address directly, suspect DNS first.
Show-IP.ir
Find your public IP address along with your country, city, ISP, time zone and location on a map. Includes VPN/proxy/Tor detection and a free subnet calculator.
Try it
Back to articles