DNS & How Names Resolve

💤0
Lv 10 XP
← 🧱 Foundations · Networking Basics

DNS & How Names Resolve

Beginner ⭐ 50 XP ⏱ 16 min #networking#dns

Understand how human names become IP addresses, and the record types you'll meet.

📖Theory

DNS is the internet’s phone book: it turns a name like example.com into an IP address. Resolution walks a hierarchy — a resolver asks the root servers, then the TLD (.com) servers, then the domain’s authoritative nameserver, caching answers along the way according to each record’s TTL.

The record types you must know:

  • A / AAAA — name → IPv4 / IPv6 address
  • CNAME — name → another name (alias)
  • MX — mail servers for a domain
  • TXT — arbitrary text (SPF, domain verification)
  • NS — which nameservers are authoritative
graph LR
  C["Client"] --> R["Resolver"]
  R --> Root["Root servers"]
  R --> TLD[".com TLD"]
  R --> Auth["Authoritative NS"]
  Auth --> R
  R --> C
A recursive DNS lookup
🌍Real-World Example
dig example.com            # full answer with record + TTL
dig +short example.com     # just the IP
dig example.com MX         # mail records
nslookup example.com       # simpler interactive lookup
dig @1.1.1.1 example.com   # query a specific resolver
✍️Hands-On Exercise
  1. Use dig +short to find the A record of a site you use.
  2. Look up the MX records for a domain and identify its mail provider.
  3. Query two different public resolvers and compare the TTL values.
  4. Explain why a DNS change you made isn’t visible yet on another machine.
🧾Cheat Sheet
RecordMapsExample
Aname → IPv493.184.216.34
AAAAname → IPv62606:2800::
CNAMEname → namewww → example.com
MXmail servers10 mail.example.com
TXTtextSPF, verification
NSnameserversns1.example.com
💬Common Interview Questions
Walk through what happens during a DNS lookup.

The resolver checks its cache, then queries the root, the TLD servers, and finally the domain’s authoritative nameserver, returning the record and caching it for the TTL duration.

What's the difference between an A record and a CNAME?

An A record points a name directly to an IP address. A CNAME points a name to another name (an alias), which is then resolved to an IP.

What is TTL and why does it matter?

Time To Live is how long a record may be cached. High TTLs reduce lookups but make changes propagate slowly; lower it before planned DNS changes.

📚Official Documentation

📝 My notes on this topic

Auto-saves as you type