How DNS turns a name into an address
DNS is the system that turns a name like example.com into an IP address. The one idea to keep: nobody knows every answer, but everyone knows who to ask next.
The short version
Names form a tree, with the root at the top. Your device asks a resolver. The resolver asks a server near the top, gets pointed down the tree, and repeats until a server that owns the name gives the address.
Step by step
- Your browser asks a resolver for the address of example.com.
- The resolver asks a root server. It replies with a referral to the servers for .com.
- The resolver asks a .com server, which refers it to the servers that hold example.com.
- The resolver asks one of those servers, which answers with an A record: a 32-bit IPv4 address.
- The resolver caches the answer for the record's TTL and returns it to the browser.
Why it matters
The TTL is why a DNS change can take time to show up: cached copies stay valid until they expire. In practice the resolver often skips steps 2 and 3, because it already knows the closest servers.
Sources
- RFC 1034, Domain names: concepts and facilities — name tree, zones, referrals, resolver algorithm, caching
- RFC 1035, Domain names: implementation and specification — TTL in seconds, A record holds a 32-bit address