The internet's phone book
DNS (Domain Name System) translates human-readable names like github.com into IP addresses like 140.82.121.3. Without DNS, every URL would be a string of numbers. With it, you only have to remember names.
What happens when you type a domain
When your browser opens github.com, a chain of lookups fires:
- OS cache — Did this machine resolve it recently?
- Router cache — Did your router resolve it recently?
- Recursive resolver — Your ISP's DNS, or a public one (1.1.1.1, 8.8.8.8). It does the heavy lifting.
- Root nameservers — "For .com, ask the .com TLD server."
- TLD nameserver — "For github.com, ask GitHub's authoritative nameserver."
- Authoritative nameserver — Returns the actual IP.
The whole dance takes milliseconds and is cached at every layer. Your browser typically only hits step 3 (the recursive resolver), because the recursive resolver caches everything below.
/etc/hosts — the override that predates DNS
Before DNS, every machine had a /etc/hosts file mapping names to IPs by hand. It still exists and is checked before DNS, which makes it incredibly useful for local overrides — pointing a domain to a different IP for testing, blocking ad servers, naming devices on your LAN.
mDNS / .local addresses
mDNS (Multicast DNS) lets devices on the same LAN discover each other by name with no DNS server involved. On macOS this is Bonjour. Any Mac on your network is reachable as hostname.local. ssh office.local works without a single line of DNS or SSH config — that's mDNS.