How Does a DNS Query Work? The Full Path From Browser to IP Address

When you type a website name, your browser first checks its own cache, then asks the operating system. If neither has the answer, the OS sends the query to a recursive resolver, usually run by your ISP, company or a public DNS service.

Jun 18, 2025 - 10:06
Updated: 
106.8k

Networking in IT Infrastructure · Explainer

How Does a DNS Query Work? The Full Path From Browser to IP Address

Quick answer: When you type a website name, your browser first checks its own cache, then asks the operating system. If neither has the answer, the OS sends the query to a recursive resolver, usually run by your ISP, company or a public DNS service. The resolver asks a root server which servers handle the top-level domain, such as .com or .in, then asks those TLD servers which servers are authoritative for the domain, and finally asks the authoritative server for the IP address. The answer travels back, every layer caches it for its TTL, and the browser connects to the IP.

Key takeaways

  • Most lookups end early because a cache already has the answer.
  • The recursive resolver does the legwork; your device only asks one question.
  • Root and TLD servers give referrals, not final answers.
  • The authoritative server holds the real record and sets its TTL.
  • Each step is a place where DNS can be attacked, and defended.

Table of Contents

Who Takes Part in a DNS Query?

ComponentRole
Stub resolverSmall client in your OS that sends the question
Recursive resolverChases the answer on your behalf and caches it
Root serversPoint to TLD servers; 13 named identities, A to M, run on many anycast sites
TLD serversPoint to the authoritative servers for a domain under .com, .in and others
Authoritative serverHolds the domain's records and gives the final answer

The terms follow RFC 9499, and the root server list is kept by IANA.

What Happens on Your Own Device First?

  1. The browser checks its own DNS cache.
  2. The OS checks its cache and the hosts file.
  3. If there is still no answer, the stub resolver sends a recursive query, normally over UDP port 53, to the configured resolver.

What Are the Steps of a Full Recursive Lookup?

Imagine the resolver has an empty cache and you ask for www.example.com. The process is described in RFC 1034 and RFC 1035.

StepWho asks whomReply
1Your device to the recursive resolverResolver starts working
2Resolver to a root serverReferral: here are the .com servers
3Resolver to a .com TLD serverReferral: here are example.com's name servers
4Resolver to example.com's authoritative serverAnswer: the A or AAAA record with a TTL
5Resolver to your deviceFinal IP address, now cached
6Browser to that IPTCP or QUIC connection, then HTTPS

Steps 2 to 4 are iterative queries: each server either answers or refers the resolver onward. If the name does not exist, the authoritative server returns NXDOMAIN, which is also cached for a time under RFC 2308.

How Do TTL and Caching Speed Things Up?

Every record has a time to live (TTL) in seconds, set by the domain owner. Until it expires, the resolver answers from memory without contacting root, TLD or authoritative servers. Root and TLD referrals have long TTLs, so a busy resolver rarely asks the root at all. Short TTLs make changes spread faster; long TTLs reduce load. This is why a DNS change can take a while to be seen everywhere.

How Can You Watch a DNS Query Yourself?

# follow the referral chain from the root (Linux or macOS)
dig +trace www.example.com

# ask your resolver and show the TTL
dig www.example.com A

# Windows
nslookup www.example.com
ipconfig /displaydns
Resolve-DnsName www.example.com

Running dig twice shows the TTL counting down, proof that the answer came from cache.

Where Can a DNS Query Be Attacked?

  • On the device: malware edits the hosts file or DNS settings.
  • On the network: plain DNS is readable and can be spoofed on a shared Wi-Fi.
  • At the resolver: cache poisoning inserts a false record for many users.
  • At the domain: stolen registrar accounts let attackers change name servers.
  • As a channel: malware hides data in DNS queries (tunnelling).

How Do DNSSEC and Encrypted DNS Protect the Query?

DNSSEC adds digital signatures so a validating resolver can tell whether records were altered. It proves authenticity but does not hide the query. Encrypted transports such as DNS over HTTPS (RFC 8484) and DNS over TLS hide queries from on-path observers. CISA guidance recommends that organisations use encrypted DNS to a trusted, filtering resolver while keeping DNS logs, which also helps meet CERT-In's 180-day log retention rule. Turn on registrar lock and multi-factor authentication for your domains.

For the bigger picture of records and zones, read our complete guide to DNS, and learn how poisoning works in DNS poisoning explained. Our networking and cybersecurity training includes DNS labs.

References

Frequently Asked Questions

The browser checks its own cache, then the operating system checks its cache and hosts file before asking any server.

It receives your question and contacts root, TLD and authoritative servers on your behalf, then caches and returns the answer.

There are 13 root server identities, lettered A to M, but each runs on many anycast sites around the world.

A recursive query asks for a final answer; an iterative query accepts a referral to another server that knows more.

TTL, or time to live, is the number of seconds a record may be cached before resolvers must look it up again.

Resolvers keep serving the old cached record until its TTL expires, so users see the change at different times.

No. DNSSEC signs records to prove they are genuine. Encryption comes from DNS over HTTPS or DNS over TLS.

Run dig +trace followed by a domain name to see each referral from the root servers down to the authoritative answer.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Wow Wow 0
Sad Sad 0
Angry Angry 0
Vaishnavi

Vaishnavi is a skilled tech professional at the Ethical Hacking Training Institute in Pune, responsible for managing and optimizing the technical infrastructure that supports advanced cybersecurity education. With deep expertise in network security, backend operations, and system performance, she ensures that practical labs, online modules, and assessments run smoothly and securely. Her behind-the-scenes contributions play a vital role in delivering a seamless and secure learning experience for aspiring ethical hackers.