Network security

How Does a DNS Server Resolve a Domain Name? (8 Steps)

A DNS lookup is a short chain of questions: your device asks a resolver, the resolver walks from the root to the authoritative server, and the answer is cached for next time.

Cysoro Security TeamPublished · 6 min read
?www.example.comWhere is this site?Root.com93.184 NETWORK SECURITY DNS resolution From name to IP in eight steps.
Quick answer

A DNS server resolves a domain name by checking its cache, then asking a root server which top-level domain server to use, asking that server which authoritative server holds the domain, and asking the authoritative server for the final IP address. The recursive resolver does this work on your behalf, caches the answer for its time-to-live, and returns the IP address to your browser.

Key takeaways

  • A DNS lookup is a chain: stub resolver, recursive resolver, root, TLD and authoritative server — each step narrows the search.
  • Most lookups end in a cache, which is why repeat visits are fast; the full walk only happens on a cold lookup.
  • Recursive queries ask one server to do the whole job, while iterative queries return referrals that the resolver must follow itself.

You type a domain name, and a website appears. Behind that simple moment is a short chain of questions between servers, each one narrowing the search until a single IP address comes back. This guide follows that chain step by step.

It is written for anyone who runs a website, manages a network, or simply wants to understand why a site sometimes fails to load. You do not need to know any commands to follow it, though we include a few you can try at the end.

How does a DNS server resolve a domain name?

A DNS server resolves a domain name by checking its cache, then walking the DNS hierarchy: it asks a root server for the top-level domain server, asks that server for the authoritative server, and asks the authoritative server for the final IP address. The answer is then cached and returned to your browser.

The Domain Name System is the phonebook of the internet, as Cloudflare explains: humans use domain names such as example.com, while browsers need IP addresses such as 93.184.216.34. DNS translates one into the other.

No single server knows every name. DNS is a distributed, hierarchical database, defined in RFC 1034 and RFC 1035. Each server knows its own zone and points to the next server down the tree.

The eight steps of a DNS lookup1Browserasks thestub resolver2Resolverchecks itscache first3Rootpoints tothe .com TLD4TLDpoints to theauthoritative NS5AnswerIP returnedand cachedMost lookups stop at step two: the cache.
Most lookups stop at step two: the cache. Illustration by Cysoro.

What are the four DNS servers in a lookup?

Four roles take part in a typical lookup: the stub resolver on your device, the recursive resolver, the root server, the TLD server, and the authoritative server. Cloudflare counts the recursor, root, TLD and authoritative servers as the four server roles, with your device as the client.

The stub resolver lives in your operating system. It does not resolve names itself; it forwards your query to the recursive resolver your network is configured to use, usually from your ISP or a public service such as 8.8.8.8 or 1.1.1.1.

The recursive resolver does the real work. It accepts your query, checks its cache, and walks the hierarchy on your behalf until it has an answer or an error. The root server points it to the TLD, the TLD points it to the authoritative server, and the authoritative server gives the final answer.

What are the eight steps in a DNS lookup?

Cloudflare describes eight steps for a cold lookup of example.com, when nothing is cached. Most real lookups skip most of these steps because the answer is already in a cache somewhere along the chain.

  1. You type example.com and the query goes to a DNS recursive resolver.
  2. The resolver queries a root nameserver for the root zone.
  3. The root responds with the address of the .com TLD server.
  4. The resolver queries the .com TLD server.
  5. The TLD responds with the IP address of the nameserver for example.com.
  6. The resolver queries that nameserver, the authoritative server for the domain.
  7. The authoritative server returns the IP address for example.com.
  8. The resolver returns the IP address to your browser, which then requests the page.

After step eight, the browser makes an HTTP request to that IP address and the web server returns the page. You can see the chain yourself with dig +trace example.com, which shows each referral in turn.

What is the difference between recursive and iterative queries?

In a recursive query, the client asks a server to return the final answer or an error, and the server does all the follow-up work. In an iterative query, a server returns the best answer it has — usually a referral to another server — and the client follows it.

In practice, the two modes combine. Your device sends a recursive query to the recursive resolver, and the resolver then sends iterative queries down the hierarchy: root, TLD, authoritative. Each server in that walk returns a referral, not the final answer, until the last one.

RFC 1034 describes both approaches and notes that the iterative approach is required, while the recursive approach is allowed as an option. That design keeps the load spread across servers instead of piling it on the root.

How does DNS caching and TTL work?

DNS caching stores an answer closer to the client so the next lookup for the same name is faster. Caching happens in the browser, the operating system, the router, and the recursive resolver, and each cached record carries a time-to-live.

The TTL is set by the owner of the record and tells a resolver how many seconds it may keep the answer. When the TTL expires, the resolver must ask again. A short TTL means changes spread quickly; a long TTL means fewer lookups and less load.

Caching is why most lookups end quickly. If the resolver already has the answer, or already knows the authoritative servers for a domain, it skips the root and TLD steps entirely. You can try this yourself with our free DNS lookup tool.

What DNS record types can a server return?

An authoritative server holds records for its zone, each with a type, a name, a TTL and data. The type tells the resolver what the record means, and different types serve different jobs.

Common DNS record typesA — IPv4 addressMaps a name to an IPv4 address, such as 93.184.216.34.AAAA — IPv6 addressMaps a name to an IPv6 address for modern networks.CNAME — aliasPoints one name to another name; the resolver then looks up the target.MX — mail serverTells other servers where to deliver mail for a domain.NS — name serverLists the authoritative servers for a zone.TXT — textHolds text records, used for SPF, DKIM and verification.
The records an authoritative server can return. Illustration by Cysoro.
RecordWhat it doesExample use
AMaps a name to an IPv4 addressexample.com to 93.184.216.34
AAAAMaps a name to an IPv6 addressIPv6-only clients and networks
CNAMEAliases one name to anotherwww pointing at a CDN hostname
MXLists mail servers for a domainDelivering email to the right server
NSLists authoritative servers for a zoneDelegation from parent to child zone
TXTHolds text dataSPF, DKIM and domain verification

If the answer is a CNAME, the resolver must start a new chase for the target name, which adds one or more steps. That is common with CDN hostnames, where a name points to another name before it points to an IP address.

Why does DNS resolution fail?

DNS fails when any link in the chain breaks: your device has the wrong resolver, the resolver is down, the authoritative server has a wrong or expired record, or the network drops the query. The error you see is usually the same — the site does not load — whatever the cause.

Start with the simplest checks. Flush your local cache with ipconfig /flushdns on Windows, then try a public resolver such as 8.8.8.8 or 1.1.1.1. If the site loads with a different resolver, your usual resolver or its cache is the problem.

For a domain you own, check the records with dig or our DNS lookup tool. A missing or wrong NS record at the registrar is a common cause of a domain that never resolves.

You can also check who runs the domain with our WHOIS lookup to confirm the registrar and nameservers are correct.

How is DNS protected against spoofing?

DNS was not designed with security built in, so attackers can try to poison a cache or spoof an answer and send you to a fake site. Three defences matter most: DNSSEC, encrypted DNS, and a trustworthy resolver.

DNSSEC adds signatures to DNS records so a resolver can check that the answer came from the authoritative server and was not changed in transit. It does not encrypt the query, but it does prove the answer is genuine.

Encrypted DNS, in the form of DNS over TLS on port 853 and DNS over HTTPS on port 443, hides the query from anyone watching the network. Together with DNSSEC and a resolver you trust, they close the most common DNS attacks. For more on protecting your own domain, see our guide to DMARC.

The bottom line

A DNS lookup is a short, practical chain: your device asks a recursive resolver, the resolver checks its cache, then walks from the root to the TLD to the authoritative server, and the answer comes back with a TTL attached.

Most of the time the cache answers and the walk never happens. When a lookup does fail, work through the chain in order — local cache, resolver, records — and you will find the break. You can start by checking any domain with the free DNS lookup tool.

Frequently asked questions

How long does DNS resolution take?

A cached lookup usually returns in milliseconds. A cold lookup that must walk from the root to the authoritative server takes longer, but still usually finishes in well under a second on a normal connection.

What is the difference between a recursive and an authoritative DNS server?

A recursive resolver takes your query and does the work of finding the answer, asking other servers as needed. An authoritative server holds the actual records for a domain and gives the final answer for that zone.

What is a DNS root server?

A root server holds the root zone, which lists the servers for every top-level domain such as .com and .org. There are 13 logical root server identities, labelled A to M, run by 12 organisations and replicated worldwide.

What is a TLD server?

A top-level domain server holds the servers for one top-level domain, such as .com. It answers a resolver by pointing it to the authoritative servers for the domain you asked about.

What does TTL mean in DNS?

TTL, or time-to-live, is the number of seconds a resolver may keep a DNS record in its cache. When the TTL expires, the resolver must ask again. Short TTLs update faster; long TTLs reduce load.

Why does DNS sometimes fail?

Common causes are a wrong DNS setting, a resolver outage, an expired or misconfigured record at the authoritative server, or a network problem. Flushing your local cache and trying a public resolver such as 8.8.8.8 or 1.1.1.1 can help narrow it down.

What is DNSSEC?

DNSSEC adds cryptographic signatures to DNS records so a resolver can check that the answer really came from the authoritative server and was not changed in transit. It protects against DNS spoofing and cache poisoning.

Does DNS use UDP or TCP?

DNS usually uses UDP on port 53 for small queries, and TCP when the answer is large or for zone transfers. Encrypted DNS uses port 853 for DNS over TLS and port 443 for DNS over HTTPS.

Sources

  1. Cloudflare — What is DNS?
  2. RFC 1034 — Domain Names: Concepts and Facilities
  3. RFC 1035 — Domain Names: Implementation and Specification
  4. ScoutDNS — How DNS Resolution Works
  5. GeeksforGeeks — Address Resolution in DNS
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against RFC 1034 and RFC 1035 and Cloudflare's DNS learning guide, which describes the eight steps of a DNS lookup.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free