What is DNS and how does it work?
The basics of DNS
DNS is often called the phonebook of the internet. When you type a domain name into your browser, your computer doesn't know where that website lives. It asks a DNS resolver, which then queries a series of servers to find the IP address associated with that name.
The process starts with your device checking its local cache. If the answer isn't there, it asks a recursive resolver, usually run by your ISP or a public service like Google DNS or Cloudflare. The resolver then queries the root servers, then the TLD (top-level domain) servers, and finally the authoritative nameservers for the domain.
Key components
Authoritative nameservers hold the actual DNS records for a domain. These records include A records (which map a name to an IPv4 address), AAAA records (IPv6), CNAME records (aliases), MX records (email), and others.
Resolvers cache answers to speed up future requests. The cache duration is controlled by the TTL (Time to Live) value set on each record, typically ranging from a few minutes to 24 hours or more.
- Root servers: direct queries to the right TLD servers.
- TLD servers: handle .com, .org, etc., and point to authoritative nameservers.
- Authoritative nameservers: store the actual DNS records for a domain.
- Recursive resolver: does the legwork and caches results.
- TTL: how long a record can be cached, in seconds.
Common mistakes
- Thinking DNS is a single database; it's actually a distributed system with many servers.
- Assuming DNS changes are instant; caching at multiple levels can delay updates.
- Confusing DNS with web hosting; DNS only points to a server, it doesn't serve content.
