DNS Resolution
dig example.com prints one answer in a few milliseconds, but dig +trace example.com prints three screens of servers handing you off, each one saying ask them instead until the last one finally answers.
- ▸Your machine never talks to a root server; it knows exactly one address, and something else does all the walking.
- ▸Thirteen root-server names answer from nearly two thousand machines, because a name is not a box.
- ▸Ask the same name twice and the second answer skips every server the first visited, until a countdown ends.
cat /etc/resolv.conf on your laptop prints a line or two, and one of them is nameserver, followed by a single IP such as 127.0.0.53 or 1.1.1.1. That is the only DNS address your machine holds. The small piece of the system that programs call to turn a name into an address, the stub resolver, does not know the root of the naming system, does not know who runs .com, does not know anything except that one server.
So when curl example.com needs an address, the stub sends one question to that one server and blocks, waiting for the finished answer. Its query carries a bit named RD, Recursion Desired, which means you do the legwork and hand me back an IP.
The server it asks is a recursive resolver, and the whole rest of this topic is what that recursive does while your stub sits and waits.