DNS (the Domain Name System) is the internet's directory service: it turns human-friendly names like www.example.com into the numeric IP addresses computers actually use to connect to each other. It does this through a distributed hierarchy of servers, with heavy caching at every step so lookups stay fast.
Almost every website visit, email and app connection starts with a DNS lookup you never see. It usually takes milliseconds. But when it breaks, nothing seems to work — even though your connection itself is fine.
Why DNS exists
Devices find each other using IP addresses such as 192.0.2.10 or 2001:db8::10. Try remembering those for every site you visit — people can't, and the numbers change anyway the moment a site moves to a new host or a new cloud region. Names don't have that problem. They're memorable, and they stay put.
That's really all DNS does: it separates the two. The name stays fixed while the address behind it shifts whenever it needs to, and DNS records simply tell everyone where to go right now. Before DNS existed, this mapping lived in one text file every computer downloaded by hand. DNS replaced that in the 1980s with a database split across thousands of servers, each one responsible for just its own slice of the namespace.
The DNS hierarchy
Domain names read right to left — general to specific. Take www.example.com. (yes, there's a trailing dot, you just never see it):
- The root is the empty label at the very end, represented by that final dot. It sits at the top of the whole tree.
- Top-level domains (TLDs) such as
.com,.orgor country codes like.deand.uksit directly below the root. - Second-level domains such as
example.comare what people actually register through a registrar. - Subdomains such as
wwwormailcan be created freely by whoever controls the domain.
Each level delegates down to the one below it. The root servers know which servers handle each TLD, the TLD servers know which name servers handle each registered domain, and those name servers hold the actual records. No single server ever sees the whole picture — and that's exactly why the system scales.
How a DNS lookup works, step by step
Four kinds of servers take part in a typical lookup. So what actually happens the first time you type www.example.com into a browser?
- Stub resolver. Your operating system carries a small built-in resolver, and it checks its own cache first (your browser checks its cache too). No answer there? It passes the question to a recursive resolver — usually one run by your ISP, or a public service you've set up yourself.
- Recursive resolver. This is the one doing the actual legwork. With no cached answer of its own, it starts at the very top and asks a root server: "Where is
www.example.com?" - Root server. It doesn't know — nobody expects it to — but it replies with a referral: the list of name servers responsible for
.com. - TLD server. The resolver asks a
.comserver next, which hands back another referral: the authoritative name servers forexample.com, sayns1.example.netandns2.example.net. - Authoritative server. The resolver finally asks one of those, and gets the real answer — an A record pointing to
192.0.2.10, for instance. - Answer and caching. The resolver hands that answer back to your device, and quietly files away everything it learned along the way, so next time most of these steps get skipped entirely.
There are 13 named root server identities (a.root-servers.net through m.root-servers.net), though each one is actually served by many physical machines scattered worldwide using anycast — the same IP address announced from dozens of locations, with your query routed to whichever is nearest. In practice, resolvers rarely even need the root, since TLD referrals stay cached for days at a time.
Caching and TTL
Imagine if every single lookup had to walk the full hierarchy — the root and TLD servers would buckle under the load, and everything would crawl. Caching is the fix. Every DNS record carries a TTL (time to live), a number of seconds telling resolvers exactly how long they're allowed to hold onto an answer before asking again.
| TTL value | Duration | Typical use |
|---|---|---|
300 | 5 minutes | Records you expect to change soon, failover setups |
3600 | 1 hour | A common default for most records |
86400 | 24 hours | Very stable records, NS delegations |
Caching happens in several places at once — your browser, your operating system, sometimes your home router, and the recursive resolver you're sharing with thousands of strangers. Even failed lookups get cached. If a name doesn't exist, the resolver remembers that "NXDOMAIN" answer for a period set by the zone's SOA record. So create a record right after someone just queried it, and they might still see "not found" for a while.
Why "DNS propagation" is really cache expiry
Change a DNS record and you'll hear the familiar line: it needs "24 to 48 hours to propagate." That phrase is doing you a disservice. Your new record goes live on your authoritative servers almost instantly — nothing is being "pushed out" anywhere. What's actually happening is that resolvers around the world are still clutching the old answer in their caches, and each one only bothers fetching the new answer once its cached copy's TTL runs out.
In practice, that means:
- Lower the TTL before a planned change. Got a record sitting at 86400? Drop it to 300 at least a day ahead of your migration. Once that old long TTL has expired everywhere, your change gets picked up within minutes.
- Changing name servers is slower. NS records at the TLD level often carry TTLs of a day or more, and you don't control them — so moving a domain to a new DNS provider genuinely does take longer.
- Different people will see different answers for a while. That's normal mid-transition, not a bug. Watch it happen for yourself with our DNS propagation checker, which compares answers across several major public resolvers.
Public resolvers and encrypted DNS
By default your device just uses whatever recursive resolver your network hands it — usually your ISP's. Prefer a public resolver instead? Cloudflare's 1.1.1.1 and Google Public DNS at 8.8.8.8 are the two everyone reaches for. Whichever one you pick can see every domain you look up, though, so choose based on a privacy policy you actually trust.
Traditional DNS travels unencrypted over port 53, meaning anyone sitting on the network path can read your queries — and potentially tamper with them too. Two standards exist to fix that:
- DNS over TLS (DoT), defined in RFC 7858, wraps DNS inside TLS on its own dedicated port, 853. Android's "Private DNS" setting runs on it.
- DNS over HTTPS (DoH), defined in RFC 8484, sends DNS queries as ordinary HTTPS requests over port 443, so they blend right in with normal web traffic. The major browsers all support it.
Encryption keeps queries private in transit, but it can't prove an answer is genuine. That's a separate job — DNSSEC's job — letting domain owners cryptographically sign their records so resolvers can catch forged responses.
Querying DNS yourself with nslookup and dig
You don't need special tools to query DNS — a terminal will do. nslookup ships with Windows, macOS and Linux alike:
nslookup www.example.com
nslookup -type=MX example.com
nslookup www.example.com 1.1.1.1
That last form sends the query to one specific resolver, handy for checking whether your local resolver is clinging to a stale cached answer. On macOS and Linux, dig gives you more to work with, including the TTL remaining on the cached entry:
$ dig www.example.com A
;; ANSWER SECTION:
www.example.com. 3600 IN A 192.0.2.10
A few variations worth knowing: dig example.com MX +short for a compact answer, dig @8.8.8.8 example.com to query a resolver of your choosing, and dig +trace www.example.com, which runs the whole root-TLD-authoritative walk itself and prints every referral along the way. Prefer a browser instead? Our DNS lookup tool queries A, AAAA, MX, TXT and other records for any domain you give it.
Frequently asked questions
What happens if DNS stops working?
Websites and apps simply fail to load, even with your connection working fine — often with errors like "server not found" or "DNS_PROBE_FINISHED_NXDOMAIN". Try connecting directly to an IP address; if that still works, you've confirmed DNS is the culprit. Switching to a different resolver usually fixes it when your ISP's own resolver is the one down.
How do I clear my DNS cache?
On Windows, run ipconfig /flushdns. On macOS, run sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder. Browsers keep their own separate cache too, so restarting the browser is worth trying. Just remember: this only clears your local cache, never your ISP's resolver.
Is DNS the same as my IP address?
No. Your IP address identifies your connection; DNS is simply the service that turns names into those addresses. The DNS servers you use do show up in your network settings, but they're a separate thing from the public IP address shown on the What's My IP Number page.
Does changing my DNS server make my internet faster?
It can shave a little time off the first connection to each new site, but it won't touch your download speed. The real payoffs are reliability, filtering and encrypted DNS.
Komentar
Bagikan tips, ajukan pertanyaan, atau ceritakan pengalaman Anda memakai alat ini.