You type a website address into your browser:
https://www.example.com
Within a short time, the browser displays the website.
But how does the computer know which server should receive the request?
The answer involves DNS resolution.
DNS resolution happens so frequently that most users never notice it. Understanding it, however, is extremely useful for web developers, cloud engineers, system administrators, network engineers, DevOps professionals, and cybersecurity learners.
What Is DNS Resolution?
DNS resolution is the process through which a DNS query is answered.
Suppose a browser needs to connect to:
www.example.com
The client may need an IPv4 or IPv6 address for the hostname.
A simplified process is:
Hostname ↓ Local Cache ↓ Recursive Resolver ↓ Root ↓ TLD ↓ Authoritative DNS ↓ DNS Answer ↓ Client
In practice, caching can eliminate some of these steps.
Why Does DNS Resolution Exist?
Humans prefer names such as:
example.com github.com codewithav.blogspot.com
Network communication ultimately uses addressing information such as IP addresses.
DNS provides a scalable naming system that connects human-readable names with machine-readable network information.
The Complete DNS Resolution Process
Let's examine what can happen when you enter a website address into a browser.
Step 1: You Enter the URL
Suppose you type:
https://www.example.com
The browser identifies the hostname:
www.example.com
The browser now needs to determine where that hostname should resolve.
Step 2: Browser Checks Its Cache
The browser may have previously resolved the hostname and stored the answer temporarily.
If the cached information is still usable, another DNS lookup may not be necessary.
Browser Cache
|
| Found?
+---+---+
| |
Yes No
| |
v v
Use Continue
Answer Lookup
Step 3: Operating System Checks DNS Information
If the browser does not have a usable answer, the operating system may have DNS information available locally.
The exact caching behavior depends on the operating system and DNS configuration.
Step 4: DNS Query Goes to a Recursive Resolver
If no suitable local answer exists, the client usually sends a DNS query to a configured recursive resolver.
The recursive resolver may be:
- Provided by an internet service provider
- Provided by an organization
- Configured manually
- Provided by another DNS service
The resolver's job is to find the answer for the client.
Step 5: Resolver Checks Its Cache
The recursive resolver may already have the requested information cached from a previous query.
If the cached record is still valid according to its TTL and caching rules, the resolver can immediately return the answer.
Client | v Resolver | +---- Cached Answer? ---- Yes ----> Return | No | v Continue DNS Resolution
Step 6: Resolver Queries the DNS Hierarchy
If the resolver does not have a usable cached answer, it can query the DNS hierarchy.
The hierarchy can involve:
- Root DNS servers
- Top-level domain servers
- Authoritative DNS servers
Step 7: Resolver Contacts a Root Server
The root system is at the top of the DNS hierarchy.
Suppose the resolver needs information for:
www.example.com
The root does not normally return the final IP address of the website.
Instead, it can direct the resolver toward the appropriate top-level-domain infrastructure, such as the infrastructure responsible for .com.
Resolver | v Root | v .com TLD Servers
Step 8: Resolver Queries the TLD Infrastructure
Next, the recursive resolver can query the DNS servers responsible for the relevant top-level domain.
For:
www.example.com
the relevant TLD is:
.com
The TLD infrastructure can provide information about the authoritative nameservers for the relevant domain.
Resolver | v .com TLD | v Authoritative Nameserver
Step 9: Resolver Contacts the Authoritative DNS Server
The resolver can then query an authoritative nameserver for the domain.
The authoritative server contains the DNS information for the zone it serves.
For example, it may return an A record:
www.example.com A 203.0.113.25
Or it may return an AAAA record for IPv6:
www.example.com AAAA 2001:db8::25
Step 10: Resolver Returns the Answer
The recursive resolver sends the result back to the client.
Authoritative DNS
|
v
Recursive Resolver
|
v
Client
|
v
IP Address
The client can now use the returned network address to establish a connection to the destination server.
Step 11: Browser Connects to the Server
DNS resolution is only one step in loading a website.
After obtaining the relevant address, the browser still needs to establish the appropriate network and application connections.
For HTTPS, this involves establishing a secure TLS connection before protected HTTP communication takes place.
DNS Resolution
↓
IP Address
↓
Network Connection
↓
TLS (for HTTPS)
↓
HTTP Request
↓
HTTP Response
↓
Website
Full DNS Resolution Diagram
User
|
v
Browser
|
v
Local DNS Cache
|
Cache Miss
|
v
Recursive Resolver
|
Cache Miss
|
v
Root
|
v
TLD DNS
|
v
Authoritative DNS
|
v
DNS Record
|
v
Recursive Resolver
|
v
Browser
|
v
Web Server
What Is Recursive DNS?
A recursive DNS query asks a resolver to obtain the answer on behalf of the client.
The resolver may perform multiple DNS queries before returning the final result.
This is why it is useful to distinguish between:
- Stub resolver/client: software on the user's system that sends DNS queries.
- Recursive resolver: DNS service that finds the requested answer.
- Authoritative server: server that provides authoritative records for a zone.
Recursive Query vs Iterative Query
DNS terminology distinguishes between recursive and iterative query behavior.
Recursive Query
The client asks the recursive resolver to obtain the final answer.
Client | | "Find the answer for me." v Recursive Resolver | v Final Answer
Iterative Query
A DNS server can respond with the best information it currently has, such as a referral to another DNS server.
Resolver | | Query v Root | | Referral v TLD | | Referral v Authoritative Server
What Is DNS Caching?
DNS caching stores DNS responses temporarily so that future queries can be answered faster without repeating the entire resolution process.
Caching can occur in different places:
- Browser
- Operating system
- Local DNS infrastructure
- Recursive resolver
Why DNS Caching Matters
Imagine that thousands of users repeatedly ask for the same domain.
Without caching, DNS infrastructure would need to repeatedly perform work to obtain the same information.
With caching:
First Query
Client → Resolver → DNS Hierarchy
|
v
Answer
|
v
Cache Result
Later Query
Client → Resolver → Cached Answer
This can reduce DNS traffic and improve response time.
What Is TTL in DNS?
TTL stands for Time to Live.
DNS records contain TTL information that helps caching systems determine how long a response can generally be retained.
For example:
example.com A 203.0.113.25 TTL: 3600
A TTL value of 3600 seconds represents one hour.
What Happens When a DNS Record Changes?
Suppose a website changes from one server address to another.
Before the change:
example.com → 203.0.113.25
After the change:
example.com → 198.51.100.50
Different recursive resolvers may temporarily return different results because they can have cached copies of the previous record.
As caches expire, new queries retrieve the updated information.
Why DNS Changes Are Not Always Immediate
Suppose a DNS record has a TTL of several hours.
A resolver that cached the old answer may continue using that cached value until its permitted cache lifetime expires.
This is why DNS changes can appear gradually across different networks.
What Is DNS Negative Caching?
DNS systems can also cache negative responses, such as the fact that a particular name does not exist.
This can reduce repeated queries for names that are known not to exist.
Negative caching behavior is controlled by DNS standards and relevant record information.
DNS Resolution and Subdomains
Consider:
api.example.com
The DNS system resolves the complete hostname according to the records and delegation configured for the relevant zone.
Different subdomains can point to different destinations:
example.com → Website www.example.com → Website api.example.com → API mail.example.com → Mail
DNS CNAME During Resolution
A hostname may resolve through a CNAME record.
For example:
www.example.com
|
| CNAME
v
app.host.example
|
| A / AAAA
v
IP Address
The recursive resolver follows the DNS records as required to obtain the relevant final answer.
DNS Resolution for IPv4
If a client needs an IPv4 address, the resolver can obtain an A record.
www.example.com
|
v
A Record
|
v
203.0.113.25
DNS Resolution for IPv6
If an IPv6 address is requested, an AAAA record can provide it.
www.example.com
|
v
AAAA Record
|
v
2001:db8::25
Modern hosts can use IPv4, IPv6, or both depending on their configuration and network connectivity.
What If DNS Returns Multiple IP Addresses?
A hostname can have multiple address records.
For example:
example.com A 203.0.113.10 example.com A 203.0.113.11 example.com A 203.0.113.12
How clients and applications use multiple addresses depends on the operating system, resolver behavior, application, and network architecture.
Multiple records can be part of architectures designed for distribution or redundancy, but DNS alone is not a complete substitute for application-aware load balancing.
DNS Resolution and Web Performance
DNS lookup is one component of the overall time needed to load a website.
A simplified sequence is:
DNS Lookup
↓
Connection Establishment
↓
TLS Handshake
↓
HTTP Request
↓
Server Processing
↓
Response
Good caching and responsive DNS infrastructure can reduce lookup overhead.
DNS Resolution and CDN Architecture
Content delivery networks can use DNS and other routing mechanisms as part of their traffic-distribution architecture.
A simplified example:
User | v www.example.com | v DNS / CDN Infrastructure | +------ Edge Location A | +------ Edge Location B | +------ Edge Location C
The exact routing process depends on the CDN and its architecture.
What Happens When DNS Fails?
If DNS resolution fails, the browser may not be able to determine where to connect.
Possible symptoms include:
- Website does not open
- DNS-related browser errors
- API requests fail
- Applications cannot connect to services by hostname
- Email delivery problems
Common DNS Errors
NXDOMAIN
NXDOMAIN indicates that the queried domain name does not exist according to the responding DNS infrastructure.
SERVFAIL
SERVFAIL indicates that the DNS server could not successfully complete the query.
Timeout
A timeout can occur when the expected DNS response does not arrive within the relevant period.
Wrong IP Address
A DNS record may exist but point to the wrong destination.
How to Troubleshoot DNS Resolution
DNS troubleshooting should proceed systematically.
Step 1: Check the Hostname
Make sure the domain or subdomain is spelled correctly.
Step 2: Use nslookup
nslookup example.com
Step 3: Use dig
dig example.com
Step 4: Query Specific Record Types
dig example.com A dig example.com AAAA dig example.com CNAME dig example.com MX dig example.com TXT
Step 5: Identify the Authoritative Nameservers
Check the NS records and query the authoritative servers where appropriate.
Step 6: Check Cached Information
A stale cached answer may explain why different networks see different results.
Step 7: Check the Destination
If DNS returns an address correctly but the website is still unavailable, the problem may be at the network, web server, application, TLS, firewall, or hosting layer instead.
DNS Resolution on Windows
Windows provides the nslookup command for DNS troubleshooting.
nslookup google.com
You can also inspect local DNS configuration with:
ipconfig /all
To clear the Windows DNS client cache, Windows provides:
ipconfig /flushdns
This clears the local DNS resolver cache maintained by the Windows DNS client.
DNS Resolution on Linux
Linux systems can use tools such as:
dig example.com nslookup example.com
Modern Linux distributions can use different DNS resolution components depending on the distribution and configuration.
How to See DNS Resolution in a Browser
Modern browser developer tools can help you inspect network activity, although the exact interface differs by browser.
You can inspect:
- Request hostname
- Connection information
- Timing information
- Response details
Browser timing tools can help separate DNS lookup time from connection and server-response time.
DNS Resolution and Cybersecurity
DNS resolution is also important in cybersecurity.
Security teams can use DNS logs to investigate suspicious activity.
Examples include:
- Unexpected domain lookups
- Known malicious domains
- Unusual query volumes
- Suspicious newly registered domains
- Unexpected external connections
DNS filtering can also block requests to categories of known malicious or unwanted domains.
DNS Resolution and DNSSEC
DNSSEC can allow validating resolvers to verify the authenticity and integrity of signed DNS data.
A simplified concept is:
DNS Data | Cryptographic Signature | v Resolver Validation | +---- Valid ----> Accept | +---- Invalid --> Reject / Error
DNSSEC does not encrypt normal DNS queries. Its purpose is different from transport encryption technologies such as DNS over HTTPS or DNS over TLS.
DNS Resolution vs DNS Propagation
These terms are related but should not be treated as identical.
| DNS Resolution | DNS Propagation |
|---|---|
| Process of obtaining DNS information | Common term for the period during which caches around the internet may still contain previous information after a change |
| Happens for DNS queries | Becomes noticeable after DNS changes |
DNS Resolution Example
Imagine a user opens:
https://api.example.com/users
The hostname is:
api.example.com
A simplified resolution path could be:
api.example.com
↓
Browser Cache
↓
OS Cache
↓
Recursive Resolver
↓
Root
↓
.com TLD
↓
Authoritative DNS
↓
A / AAAA Record
↓
IP Address
↓
HTTPS Connection
↓
/users API Endpoint
This illustrates an important point: DNS resolves the hostname; DNS does not process the HTTP API request itself.
What DNS Does Not Do
DNS is sometimes misunderstood as a system that handles the entire internet connection.
DNS does not itself:
- Render a website
- Process your application's business logic
- Replace HTTP
- Replace HTTPS
- Act as a database for application records
- Guarantee that a website is secure
Its primary role is naming and DNS information resolution.
DNS Resolution Interview Questions
What is DNS resolution?
DNS resolution is the process of obtaining DNS information for a hostname, often an IP address.
What is a recursive DNS resolver?
A recursive resolver obtains DNS answers on behalf of clients, using cached information or querying other DNS infrastructure as necessary.
What is an authoritative DNS server?
An authoritative server provides the authoritative DNS records for a zone.
What is the role of a root DNS server?
The root DNS system helps direct DNS queries toward the appropriate top-level-domain infrastructure.
What is the role of a TLD DNS server?
TLD DNS infrastructure helps a resolver locate the authoritative nameservers for domains under a particular top-level domain.
What is DNS caching?
DNS caching temporarily stores DNS responses so they can be reused for future queries.
What is TTL?
TTL specifies how long DNS information can generally remain cached before needing refresh according to DNS caching behavior.
Why does DNS resolution sometimes take longer?
Resolution time can be affected by cache misses, network latency, resolver performance, DNS infrastructure availability, and the number of queries required.
What is NXDOMAIN?
NXDOMAIN indicates that the queried domain name does not exist according to the responding DNS system.
What is DNSSEC?
DNSSEC adds cryptographic signatures that allow validating resolvers to verify the authenticity and integrity of DNS data.
Frequently Asked Questions
How does DNS resolution work?
A client first checks available local information and then typically asks a recursive resolver. If necessary, the resolver queries the DNS hierarchy, including root, TLD, and authoritative DNS infrastructure, before returning the answer.
How long does DNS resolution take?
It varies. Cached responses can be very fast, while cache misses may require additional network queries.
What happens if DNS resolution fails?
The client may be unable to connect to the hostname. Depending on the failure, tools or browsers may report errors such as NXDOMAIN, SERVFAIL, or timeout-related failures.
What is the difference between recursive and authoritative DNS?
A recursive resolver finds answers for clients, while an authoritative server provides authoritative DNS records for the zones it serves.
Does DNS resolution happen every time I open a website?
Not necessarily. Browser, operating-system, local-network, and recursive-resolver caches can prevent a full DNS lookup from occurring every time.
Can DNS return more than one IP address?
Yes. A hostname can have multiple A or AAAA records.
Does DNS resolution use TCP or UDP?
Traditional DNS commonly uses UDP and can also use TCP. The exact transport depends on the query and DNS communication requirements.
Is DNS secure?
Traditional DNS does not encrypt ordinary queries. Security and privacy can be improved using technologies such as DNSSEC, DNS over HTTPS, or DNS over TLS, each serving different purposes.
```Final Thoughts
DNS resolution is one of the hidden processes that happens whenever software needs to translate a hostname into useful network information.
The simplified path to remember is:
Hostname ↓ Local Cache ↓ Recursive Resolver ↓ Root ↓ TLD ↓ Authoritative DNS ↓ IP Address / DNS Answer ↓ Network Connection
The most important concepts are recursive resolvers, authoritative DNS, root servers, TLD servers, DNS records, caching, TTL, CNAME, A/AAAA records, and DNS troubleshooting.
Once you understand DNS resolution, many concepts in web hosting, cloud computing, APIs, cybersecurity, Linux administration, and DevOps become easier to understand.
When a website is not opening, separate the problem into layers: DNS → network connectivity → TLS/HTTPS → web server → application → database. This makes troubleshooting much more systematic.
Related Articles on CodeWithAV
What Is DNS? Complete Beginner Guide
What Is the Internet and How Does It Work?
What Happens When You Type a URL?
HTTP Status Codes Every Developer Should Know
Explore More Networking and Web Development Guides
CodeWithAV — Learn, Discover & Build.