THE PENTEST LAB

How DNS Works: The Complete DNS Resolution Process

Learn how your browser finds a website's IP address. Follow the complete DNS journey through recursive resolvers, root servers, TLD nameservers and authoritative DNS, with animated diagrams and practical examples. This beginner-friendly networking tutorial also explains DNS records, caching, TTL and their role in cybersecurity.

DNS Fundamentals: Complete Study Notes

Read the complete networking lesson below. These notes cover every scene in the interactive DNS tutorial.

1. The Mystery Behind Every Website

Imagine typing youtube.com into Chrome. The website loads even though you never entered its IP address.

Networks use IP addresses to deliver packets, so your browser needs network address information to contact the right server.

DNS helps find this information using the domain name.

Real-life example: You type youtube.com rather than remembering a numeric server address.
  • Users normally access websites using easy-to-remember domain names.
  • Network communication uses IP addresses to reach destinations.
  • A browser may need DNS information before contacting a website.
  • DNS helps find address information associated with a domain.

2. Domain Names and IP Addresses

A domain name is a human-friendly name used to access websites and online services.

An IP address identifies a network interface and supports routing packets toward a destination.

DNS helps connect domain names with the network information applications need.

Think of a contact saved as Rahul in your phone. You remember the name, while your phone uses the associated number.
  • Domain names are easier to remember than numeric IP addresses.
  • IP addresses support network addressing and packet delivery.
  • DNS can return IP addresses associated with a domain name.
  • 203.0.113.10 is a documentation-only example IPv4 address.

3. What Is DNS?

DNS stands for Domain Name System.

It is a distributed system that stores and provides information about domain names, including IP addresses and mail servers.

DNS is not one enormous server. Different nameservers manage different portions of the DNS hierarchy.

DNS is similar to a phone directory, but its information is distributed across many servers.
  • DNS stands for Domain Name System.
  • DNS provides domain-related information.
  • DNS is distributed across many servers.
  • Resolvers and authoritative nameservers perform different roles.

4. What Is a DNS Resolver?

A DNS resolver helps find DNS information on behalf of a device or application.

A recursive resolver can check cached answers before contacting other DNS servers.

If the answer is missing, it can query the DNS hierarchy to find the requested records.

A college receptionist checks a directory or contacts another department to help you find a teacher's office.
  • Recursive resolvers search for DNS answers on behalf of clients.
  • Resolvers can reuse valid cached information.
  • A missing answer may require additional DNS queries.
  • Examples of public DNS resolvers include Cloudflare 1.1.1.1 and Google 8.8.8.8.

5. What Is a Root DNS Server?

Root DNS nameservers are at the top of the public DNS hierarchy.

They usually do not return the final IP address for a website such as youtube.com.

Instead, they refer the resolver to the appropriate top-level domain nameservers.

A library's main directory tells you which section contains the book you need, rather than handing you the book itself.
  • Root nameservers are at the top of the DNS hierarchy.
  • They provide referrals toward TLD nameservers.
  • A youtube.com lookup can receive a referral to .com nameservers.
  • Root nameservers normally do not return a website's final A record.

6. What Is a TLD Server?

TLD means Top-Level Domain, such as .com, .org or .in.

A TLD nameserver provides delegation information for domains registered beneath that TLD.

For example, .com nameservers can direct the resolver toward the authoritative nameservers for youtube.com.

youtube.com uses .com, wikipedia.org uses .org, and thepentestlab.in uses .in.
  • TLD stands for Top-Level Domain.
  • The final label of a domain is its TLD.
  • TLD nameservers provide domain delegation information.
  • They direct resolvers toward authoritative nameservers.

7. What Is an Authoritative DNS Server?

An authoritative DNS nameserver is responsible for providing official DNS data for a zone.

It can return records such as A, AAAA, MX and other records when they exist.

An authoritative DNS server and a website server perform different jobs.

An A record may associate a domain with an IPv4 address such as 203.0.113.10. This is an example address, not YouTube's real IP.
  • Authoritative nameservers provide DNS data for zones they manage.
  • A records provide IPv4 addresses.
  • AAAA records provide IPv6 addresses.
  • DNS servers provide records, while web servers provide website content.

8. Complete DNS Resolution Process

Your device may first check locally available DNS information before asking a recursive resolver.

If the answer is not cached, the resolver can query root, TLD and authoritative nameservers.

The resolver returns the DNS answer to the device, allowing the browser to continue connecting to the required server.

The resolver communicates with each DNS nameserver separately and follows the referrals until it receives the requested answer.
  1. The browser or operating system checks available DNS information.
  2. The device asks its recursive DNS resolver.
  3. The resolver queries a root nameserver and receives a TLD referral.
  4. The resolver queries the TLD nameserver and receives an authoritative referral.
  5. The resolver queries the authoritative nameserver for the requested record.
  6. The resolver returns the answer to the device.
  7. The browser can then establish the appropriate connection to the website.

9. DNS Record Types and Their Uses

DNS supports different record types for different purposes.

A and AAAA records provide IP addressing information. CNAME records create aliases.

MX records relate to email delivery, NS records identify nameservers, and TXT records carry text data.

A domain can use A or AAAA records for web access, MX records for mail routing and TXT records for verification or email security.
  • A records contain IPv4 addresses.
  • AAAA records contain IPv6 addresses.
  • CNAME records create hostname aliases.
  • MX records identify mail servers.
  • NS records identify nameservers.
  • TXT records store text information.
Record Purpose Example
A IPv4 address 203.0.113.10
AAAA IPv6 address 2001:db8::10
CNAME Hostname alias www.example.com → example.com
MX Mail server 10 mail.example.com
NS Nameserver ns1.example.com
TXT Text information Domain verification

The values in this table are illustrative examples, not actual DNS records for The Pentest Lab.

10. DNS Caching and TTL

DNS caching temporarily stores answers so repeated lookups can be faster.

TTL stands for Time To Live. It controls how long DNS records can normally be reused from cache.

When cached information expires, a resolver may need to request updated information.

A TTL of 300 seconds represents five minutes. Actual caching behavior can vary between systems.
  • DNS caches can exist in browsers, operating systems and recursive resolvers.
  • Caching reduces repeated DNS queries.
  • TTL specifies the normal cache lifetime of a DNS record.
  • Old cached answers may remain until expiry after DNS changes.

11. Practical Demonstration: DNS Commands

Windows includes nslookup, a command-line utility for making DNS queries.

You can request a domain's address records, MX records or nameserver information.

Results depend on the domain configuration and the DNS resolver answering the query.

Open Windows Command Prompt and use nslookup to examine public DNS records.
  • nslookup queries DNS records.
  • A normal lookup requests address information.
  • The -type=MX option requests mail records.
  • The -type=NS option requests nameserver records.

Find DNS address records

nslookup thepentestlab.in

Find IPv4 records

nslookup -type=A thepentestlab.in

Find IPv6 records

nslookup -type=AAAA thepentestlab.in

Find mail server records

nslookup -type=MX thepentestlab.in

Find nameserver records

nslookup -type=NS thepentestlab.in

Find TXT records

nslookup -type=TXT thepentestlab.in

12. DNS and Cybersecurity

DNS is important for security because it helps direct applications to network destinations.

Manipulated DNS responses can cause a device to attempt to contact the wrong server.

However, changing a DNS answer does not automatically defeat HTTPS certificate validation.

If a false DNS response points a legitimate domain to the wrong IP address, a browser may attempt that destination. HTTPS verification can still block an impersonating server.
  • DNS spoofing involves false DNS information.
  • DNS cache poisoning can cause incorrect answers to be stored or reused.
  • Incorrect DNS answers may redirect connection attempts.
  • HTTPS certificate validation provides an important independent protection.

DNSSEC helps validate the authenticity and integrity of DNS data for properly signed zones. DNS over HTTPS (DoH) and DNS over TLS (DoT) can protect DNS queries in transit between a client and its resolver.

13. Final Recap: How DNS Works

DNS helps applications find domain-related information such as IP addresses.

Recursive resolvers, root nameservers, TLD nameservers and authoritative nameservers work together to answer queries.

DNS records, caching and TTL make this system useful for websites, email and other services.

After DNS resolution, a browser can continue establishing its connection and exchanging HTTP requests and responses.
  • DNS connects domain names with useful network information.
  • Resolvers use caches and the DNS hierarchy.
  • DNS records provide address, alias, mail and nameserver information.
  • After DNS resolution, the browser can communicate with the required server.

Frequently Asked Questions About DNS

What is DNS in simple words?

DNS is the Domain Name System. It helps applications find information associated with domain names, including their IP addresses.

What happens when you type a URL?

If the required address is not already available, the browser or operating system can request DNS information from a resolver. The browser then uses the result to connect to the appropriate server.

Is DNS a server or a protocol?

DNS is a distributed naming system with protocols and servers used to store, query and return domain-related information.

What port does DNS use?

Traditional DNS commonly uses UDP and TCP port 53. Encrypted DNS services may use other ports and transport protocols.

What is the difference between DNS and HTTP?

DNS helps resolve domain-related information, such as an IP address. HTTP is an application protocol used to exchange requests and responses between clients and servers.

Why is DNS important in cybersecurity?

DNS is important for asset discovery, network troubleshooting, security monitoring and understanding malicious domain activity. It also helps security professionals examine domain infrastructure during authorized assessments.

Continue Learning Networking

NEXT EPISODE · 04

How HTTP Actually Works

Now that you understand DNS, learn how your browser sends HTTP requests and receives responses.

Next Tutorial →

Practice Your Networking Skills

Test your understanding of DNS records, IP addressing and network protocols through interactive practice challenges.

Explore Practice Labs →