Skip to content
Back to Series Networking from Scratch
Networking

Getting to Know DNS: What It Is and How It Works

A complete explanation of DNS (Domain Name System), from the basic concepts to the behind-the-scenes process of how domain names resolve to IP addresses.

A
Alif Afriza Author
· · 3 min read
Getting to Know DNS: What It Is and How It Works

What is DNS?

DNS, or the Domain Name System, is the system that translates domain names (like google.com) into IP addresses (like 142.250.80.46). Without DNS, we would have to memorize the IP address of every website we want to visit.

A Simple Analogy

Think of DNS as the internet’s phone book:

  • Domain name = A person’s name
  • IP address = A phone number

When you type “google.com” into your browser, DNS looks up the matching IP address, and then the browser contacts the server at that address.

How DNS Works

Here are the steps that happen when you access a website:

  1. Browser Check - The browser checks its local cache
  2. OS Cache - If nothing is there, the OS checks its cache
  3. Router Cache - The router also has a DNS cache
  4. ISP DNS - The query is sent to the ISP’s DNS server
  5. Root DNS - If it is not found, the query goes to a root server
  6. TLD Server - The root server points to the TLD server (.com, .id, etc.)
  7. Authoritative DNS - The TLD server points to the domain’s DNS server
  8. Response - The IP address is returned to the browser
Browser → OS → Router → ISP DNS → Root → TLD → Authoritative → IP Address

DNS Records

RecordFunctionExample
ADomain to IPv4example.com → 93.184.216.34
AAAADomain to IPv6example.com → 2606:2800:220:1::248
CNAMEDomain aliaswww → example.com
MXMail serverexample.com → mail.example.com
TXTInformational textDomain verification, SPF, DKIM
NSDNS serverDomain → ns1.example.com

Self-Hosted DNS with Pi-hole

In a homelab, you can run Pi-hole as a DNS server:

# Install Pi-hole in Docker
docker run -d \
  --name pihole \
  -p 53:53/tcp \
  -p 53:53/udp \
  -p 80:80 \
  -e TZ=Asia/Jakarta \
  pihole/pihole:latest

Pi-hole features:

  • Ad-blocking - Block ads across the entire network
  • DNS over HTTPS - Encrypt DNS queries
  • Query logging - Monitor DNS activity
  • Custom rules - Create your own blocking rules

DNS Security Tips

  1. Use DNS over HTTPS (DoH) or DNS over TLS (DoT)
  2. Consider self-hosted DNS for more privacy
  3. Use DNS filtering to block malware
  4. Back up your DNS configuration

Conclusion

DNS is the foundation of the internet that is often overlooked. By understanding DNS, you can:

  • Troubleshoot network problems
  • Improve security and privacy
  • Optimize browsing performance
  • Build a better homelab infrastructure
Open for Contributors

Your ideas deserve to be read by thousands of people.

ByteNesia is built for everyone. If you have experience, tutorials, or opinions about technology, write and share them here. Your name will be credited as a contributor.

Write anything: tool reviews, homelab tutorials, security tips, or your tech stories.

Discussion & Comments