I gave a lightning talk at the Bath Ruby Conference on how domain names are resolved. Trying to pack 100ms of network chatter into 5 minutes proved tricky!
3. –Phil Karlton
“There are only two hard things in Computer
Science: cache invalidation and naming things.”
4.
5.
6.
7.
8.
9.
10. A Sneak Peek at The
Internet
http://the-internet.woss.name/
Editor's Notes
DNS involves both.
Local resolver
Machinations underneath gethostbyname()
Checks local cache and /etc/hosts
Knows the IP address of a name server (via DHCP or static configuration)
Sends the request off to the name server and waits for a response
Recursive name server:
Often first hop is your home router
Responds from its local cache if possible
If not, it attempts to resolve the address by:
Querying its upstream (ISP name server?)
Querying the root servers (well known IP addresses)
Root server
13 well-known IP addresses of root servers
Really hundreds of machines distributed globally
Authoritative for the root zone
Knows the authoritative name server for .com, .net, .uk, etc.
Ask for the A record for woss.name
Doesn’t know the answer, but knows where to ask next
Returns a list of NS records for . name
Also returns a list of A records for the name servers in .name
Glue records
Authoritative name server for .name
Ask for the A record for woss.name
Doesn’t know the answer for the A record
Knows which servers to ask next
Returns the NS records for woss.name
No glue records this time, so recursive server has to look up kara.ns.cloudflare.com
Finally, an authoritative server for woss.name
Asks for an A record for woss.name
This server is authoritative
Returns the A record for woss.name
Recursive name server:
Receives the response for woss.name
Caches it
Returns the query back to the client
Client:
Receives the result.
Caches it
Returns the DNS lookup to the application that requested it.
All happens before a web request even begins.