DNS at a glance
Key idea
Computers connect to IP addresses, but people type names. DNS turns one into the other. No single server knows every name: a resolver asks a chain of servers, each pointing to the next, until it reaches the one that holds the answer.
Step through a lookup for app.example.com:
From a name to an address
- 1Browser Resolver Where is app.example.com?
Step 1 of 6
Your device asks a resolver, usually run by your network or a public service. If the resolver answered this recently, it replies from its cache and the lookup ends here.
The cast
- Your device doesn't do the walking. It asks a resolver, usually run by your network or internet provider, or a public one you've chosen.
- Root servers know who runs each top-level domain, like
.comor.org. - Top-level domain servers know which nameservers each domain uses.
- A domain's own nameservers, called authoritative, hold its records. They're the only ones that know the answer for certain.
Why it's fast anyway
Four round trips for every page would be slow. It rarely happens, because answers are cached at every level: your browser, your operating system and the resolver all keep recent answers. The resolver almost always knows where .com is already, and popular names are answered straight from its memory.
That caching is also why DNS changes don't show up everywhere at once. Lesson 1.5.3 covers how long answers are kept.
What you get back
The answer is a record: the name, its type, and a value. For a website that's usually an address, like 203.0.113.10. The next lesson covers the record types you'll use.
Once the browser has the address, DNS is done and the browser connects to it. The name still travels inside the request, which is how one server can host many sites (lesson 1.6.1).
Where your computer looks first
Before asking a resolver, your computer checks its hosts file (/etc/hosts on macOS and Linux, C:\Windows\System32\drivers\etc\hosts on Windows). A line there overrides DNS for that machine only. localhost never needs DNS either: your own computer answers it.
Check yourself