>_

Understanding DNS: How the Internet Finds Everything

A practical guide to DNS — how domain resolution works, common DNS record types, caching, recursive resolvers, and real-world troubleshooting tips.

#dns #networking #internet #devops #infrastructure

Every time you open a website, send an email, or connect to an API, DNS is quietly working behind the scenes.

The Domain Name System (DNS) acts like the internet’s phonebook, translating human-friendly domain names like google.com into machine-readable IP addresses like 142.250.190.14.

Without DNS, we’d have to memorize IP addresses for every website we use.

In this guide, we’ll break down:


What is DNS?

DNS stands for Domain Name System.

It is a distributed and hierarchical system responsible for converting domain names into IP addresses.

For example:

salilkayastha.com.np -> 104.21.32.1

Your browser cannot directly understand domain names. It needs an IP address to establish a connection.

DNS bridges that gap.


How DNS Works

When you type a domain into your browser, several steps happen behind the scenes.

Let’s say you visit:

https://example.com

DNS Resolution Flow

Browser

OS Cache

Recursive Resolver (ISP / Cloudflare / Google DNS)

Root Nameserver

TLD Nameserver (.com)

Authoritative Nameserver

IP Address Returned

Step-by-Step DNS Lookup

1. Browser Cache Check

Your browser first checks whether it already knows the IP address.

If cached:

example.com -> 93.184.216.34

No external lookup is needed.


2. Operating System Cache

If the browser doesn’t know the answer, your operating system checks its DNS cache.

On Linux:

systemd-resolve --statistics

On macOS:

sudo dscacheutil -flushcache

3. Recursive Resolver

If the answer still isn’t found, the request goes to a recursive DNS resolver.

This is usually provided by:

The recursive resolver performs the heavy lifting.


4. Root Nameserver

The resolver asks a root DNS server:

Where can I find .com?

The root server responds with the address of the .com TLD nameservers.


5. TLD Nameserver

The resolver then asks the .com nameserver:

Where can I find example.com?

The TLD server responds with the authoritative nameserver.


6. Authoritative Nameserver

Finally, the resolver asks the authoritative server:

What is the IP address for example.com?

The authoritative server responds:

example.com -> 93.184.216.34

The resolver caches this result and returns it to your browser.


Recursive vs Authoritative DNS

Understanding this difference is important.

TypePurpose
Recursive ResolverFinds the answer on behalf of the client
Authoritative ServerStores the actual DNS records

Examples

Recursive DNS:

1.1.1.1
8.8.8.8
9.9.9.9

Authoritative DNS Providers:


DNS Caching

DNS responses are cached to reduce lookup time and improve performance.

Each DNS record contains a:

TTL (Time To Live)

Example:

example.com 300 IN A 93.184.216.34

Here:

Why TTL Matters

Lower TTL:

Higher TTL:


DNS Propagation

When you change DNS records, the changes are not instantly visible everywhere.

This delay is called:

DNS propagation

In reality, propagation mostly means:

cached records have not expired yet

Propagation time depends on:


Common DNS Record Types

DNS supports many record types.

Here are the most important ones.


A Record

Maps a domain to an IPv4 address.

example.com -> 93.184.216.34

Example:

example.com. IN A 93.184.216.34

Used for:


AAAA Record

Maps a domain to an IPv6 address.

Example:

example.com. IN AAAA 2606:2800:220:1:248:1893:25c8:1946

IPv6 adoption is increasing rapidly.

Modern infrastructure should support both:


CNAME Record

Creates an alias from one domain to another.

Example:

www.example.com. IN CNAME example.com.

Meaning:

www.example.com points to example.com

Important Limitation

A CNAME cannot coexist with other records at the same hostname.

For example, this is invalid:

example.com. IN CNAME app.example.com.
example.com. IN MX mail.example.com.

MX Record

Defines mail servers for a domain.

Example:

example.com. IN MX 10 mail.example.com.

Lower priority number means:

higher preference

Used for:


TXT Record

Stores arbitrary text data.

Very commonly used for:

Example:

example.com. IN TXT "v=spf1 include:_spf.google.com ~all"

NS Record

Specifies authoritative nameservers for a domain.

Example:

example.com. IN NS ns1.cloudflare.com.
example.com. IN NS ns2.cloudflare.com.

These records tell the internet:

who is responsible for this domain

PTR Record

Used for reverse DNS lookups.

Instead of:

Domain -> IP

PTR performs:

IP -> Domain

Very important for:


SRV Record

Defines services available on a domain.

Example:

_sip._tcp.example.com. IN SRV 10 5 5060 sipserver.example.com.

Commonly used in:


SOA Record

SOA stands for:

Start of Authority

Contains administrative information about the DNS zone.

Example:

example.com. IN SOA ns1.example.com. admin.example.com. (
  2026050601 ; serial
  3600       ; refresh
  1800       ; retry
  1209600    ; expire
  86400      ; minimum TTL
)

DNS Zones

A DNS zone is a portion of the DNS namespace managed by a specific administrator.

Example:

example.com

The zone contains:

Zone files are often stored in BIND format.


DNS Over HTTPS (DoH)

Traditional DNS queries are unencrypted.

This means:

DNS over HTTPS encrypts DNS requests using HTTPS.

Examples:


DNSSEC

DNSSEC adds cryptographic signatures to DNS records.

Its purpose is to prevent:

Without DNSSEC:

attackers may fake DNS responses

DNSSEC helps clients verify authenticity.


Common DNS Tools

dig

The most popular DNS debugging tool.

dig example.com

Query a specific resolver:

dig @1.1.1.1 example.com

Get MX records:

dig example.com MX

nslookup

Simple DNS query utility.

nslookup example.com

host

Another lightweight DNS lookup tool.

host example.com

Troubleshooting DNS Issues

DNS problems are extremely common in production environments.

Verify Resolution

dig example.com

Check:


Verify Nameservers

dig NS example.com

Verify Mail Records

dig MX example.com

Trace Full Resolution Path

dig +trace example.com

This shows:


Real-World Example

Suppose your infrastructure looks like this:

Frontend  -> Vercel
API       -> AWS EC2
Email     -> Google Workspace

Your DNS records may look like:

example.com.      IN A      44.201.10.20
www.example.com.  IN CNAME  cname.vercel-dns.com.
example.com.      IN MX     1 aspmx.l.google.com.
example.com.      IN TXT    "v=spf1 include:_spf.google.com ~all"

Best Practices

Use Multiple Nameservers

Avoid single points of failure.


Enable DNSSEC

Protect against spoofing attacks.


Set Reasonable TTLs

Recommended:

300 seconds during migrations
3600+ seconds for stable systems

Monitor DNS Expiry

Expired domains can cause major outages.

Use monitoring tools like:


Use Reliable DNS Providers

Popular choices:


Final Thoughts

DNS is one of the foundational technologies of the internet.

Even though it usually works silently in the background, understanding how DNS operates is essential for:

Whether you’re deploying Kubernetes clusters, managing production APIs, or troubleshooting email delivery, DNS knowledge becomes incredibly valuable.

The better you understand DNS, the easier infrastructure debugging becomes.


Back to all posts