Skip to main content

📞 DNS

The phone book of the internet

The Phonebook Analogy

Looking up a friend's phone number:

StepAction
You know"John Smith"
Phonebook gives"555-1234"
You call555-1234

DNS is the internet's phonebook. You know "google.com", DNS gives you an IP address (like <ip-address>), your browser connects.


What Is DNS?

DNS = Domain Name System

FunctionExample
Translates names to IPsexample.com → <ip-address>
Human-friendlymysite.com → (an IP address)

Without DNS, you'd memorize IP addresses instead of domain names. No thanks!


Why We Need DNS

Humans vs Computers

Humans RememberComputers Need
Words, namesNumbers (IP addresses)
google.com(an IP address)
facebook.com(an IP address)

DNS bridges the gap.

IP Addresses Change

Note: IPs for big sites can change frequently; DNS is what makes that seamless.

EventWith DNS
Website moves serversDNS updated once
Users type same domainWorks automatically
IP changes from <old-ip> to <new-ip>Most users won't notice

How DNS Works

The Lookup Process

StepWhat Happens
1You type: www.example.com
2Browser checks cache → miss
3OS checks cache → miss
4Ask DNS resolver (usually ISP)
5Resolver asks root nameserver
6Root says: "Ask .com TLD"
7.com TLD says: "Ask example.com's nameserver"
8Nameserver returns: <ip-address>
9Browser connects to that IP

Uncached lookups are often tens of milliseconds (can be more). Cached results are usually near-instant.

The DNS Hierarchy

                    ┌─────────┐
                    │  Root   │  (knows about TLDs)
                    │    .    │
                    └────┬────┘
                         │
          ┌──────────────┼──────────────┐
          │              │              │
     ┌────▼────┐    ┌────▼────┐    ┌────▼────┐
     │  .com   │    │  .org   │    │  .net   │
     │   TLD   │    │   TLD   │    │   TLD   │
     └────┬────┘    └─────────┘    └─────────┘
          │
    ┌─────▼──────┐
    │example.com │  (authoritative nameserver)
    └────────────┘

DNS Record Types

RecordPurposeExample
ADomain → IPv4example.com → <ipv4-address>
AAAADomain → IPv6example.com → <ipv6-address>
CNAMEAlias to another domainwww → example.com
MXMail server locationexample.com → mail.example.com
TXTText data (SPF, verification)"v=spf1 include:..."
NSAuthoritative nameserversns1.example.com

Example DNS Configuration

TypeNameValuePurpose
A@<ip-address>Root domain
Awww<ip-address>www subdomain
CNAMEblogmedium.comBlog alias
MX@mail.example.comEmail routing
TXT@"v=spf1..."Email auth

DNS Caching

Why Cache?

Without CacheWith Cache
Full lookup: often tens of msCached: near instant
Same request repeatedUse stored answer
Network overheadLocal response

Cache Levels

LevelDurationLocation
BrowserSeconds-minutesYour browser
OSMinutesYour computer
RouterMinutesHome router
ISP resolverHoursISP servers

Each level checked before full lookup.

TTL (Time To Live)

TTLMeaningTrade-off
Short (minutes)Cache brieflyQuick updates, more lookups
Medium (hours)Cache for a whileBalanced
Long (day+)Cache for longerFewer lookups, slower updates

DNS Resolver

Your DNS resolver does the heavy lifting:

Popular ResolverIP AddressFeatures
Google<resolver-ip>Popular, widely available
Cloudflare<resolver-ip>Often fast, privacy-focused
OpenDNS<resolver-ip>Security filtering

Why Change Resolver?

ReasonBenefit
SpeedSome resolvers can be faster for you
PrivacyLogging/retention policies vary
SecurityBlock malware domains
CensorshipMay help in some cases

Common DNS Problems

DNS Propagation

ScenarioWhat Happens
Changed DNS recordsTakes time to spread globally
Old TTL not expiredDifferent users see different results
"Propagation time"Minutes to a couple of days in some cases

DNS Not Resolving

SymptomPossible Cause
"Server not found"DNS server down
Domain expiredRegistration lapsed
Misconfigured recordsWrong IP or typo

Solution: Flush DNS cache, try different resolver.


DNS Security

Threats

AttackDescription
DNS HijackingRedirects queries to malicious IPs
DNS SpoofingFake responses for phishing
DNS TunnelingExfiltrate data via DNS queries

Protections

TechnologyPurpose
DNSSECSigns records cryptographically
DNS over HTTPS (DoH)Encrypts DNS queries
DNS over TLS (DoT)Encrypted DNS transport

FAQ

Q: How long does DNS lookup take?

Uncached: often tens of milliseconds (can be more). Cached: usually near-instant.

Q: Why does my site show old content after DNS change?

DNS propagation. Old cached records haven't expired. Wait or flush caches.

Q: Is a public DNS resolver better than my ISP's DNS?

It depends on your network and location. You can try a few public resolvers and see what performs well for you.

Q: Can DNS be used for censorship?

Yes. Networks can block or tamper with DNS. VPNs and encrypted DNS (DoH/DoT) can help in some cases, but they don't bypass every kind of blocking.


Summary

DNS translates human-friendly domain names into IP addresses that computers use to connect.

Key Takeaways:

  • DNS is the internet's phonebook
  • Hierarchical system: root → TLD → domain
  • Common records: A, AAAA, CNAME, MX, TXT
  • Caching speeds up repeated lookups
  • TTL controls cache duration
  • DNSSEC and DoH add security/privacy
  • Many popular public resolvers exist

Without DNS, we'd be memorizing IP addresses!

Related Concepts

Leave a Comment

Comments (0)

Be the first to comment on this concept.

Comments are approved automatically.