DNS
Phonebook for the internet. Turns names into IP addresses.
What it is
When you type google.com, your computer doesn’t know where that is. DNS servers translate human-readable domain names into IP addresses that computers can route to.
The lookup chain
- Browser cache - already know it?
- OS cache -
/etc/hostsor system DNS cache - Router cache
- ISP’s DNS resolver
- Root nameservers → TLD nameservers → Authoritative nameservers
Record types
| Type | What it does | Example |
|---|---|---|
| A | Domain → IPv4 | example.com → 93.184.216.34 |
| AAAA | Domain → IPv6 | example.com → 2606:2800:... |
| CNAME | Alias to another domain | www → example.com |
| MX | Mail server for domain | mail.example.com |
| TXT | Arbitrary text (SPF, DKIM, verification) | "v=spf1 include:..." |
| NS | Nameserver for domain | ns1.example.com |
Common gotchas
- TTL caching: Changed DNS? Might take hours to propagate. TTL controls this.
- CNAME at root: Can’t have CNAME on naked domain (
example.com). Use ALIAS/ANAME if provider supports it. - Trailing dots:
example.com.(with dot) is fully qualified. Some tools care.
Debug commands
# Basic lookup
dig example.com
# Specific record type
dig example.com MX
# Trace full resolution path
dig +trace example.com
# Use specific DNS server
dig @8.8.8.8 example.com
# Quick and dirty
nslookup example.com