System Design
Networking
DNS

DNS explained

subdomain: www domain: google top-level domain: com

Classic interview question on what happens when you type in a URL in the browser

  1. DNS query is made to figure out which IP address is associated with hostname

    • attempts to look into local cache
    • if empty, needs to look up IP address from the web's phone book, which is the job of the recursive resolver
  2. Recursive resolver is recursive because it needs to make multiple requests to other servers, starting with the root nameserver

    • root nameserver: knows the IP address of the TLD nameserver
    • TLD nameserver: knows the IP address of the authoritative nameserver
    • authoritative nameserver: knows the IP address of the domain name
  3. Once the recursive resolver has the IP address, it returns it to the browser and cached

Other parts of DNS

  • address record (A record): maps hostname(domain/subdomain) to IP address
  • canonical name record (CNAME): forwards one domain to another domain
  • mail exchanger record (MX record): maps email domain to email server
  • text record (TXT record): used to store text-based information related to the domain (often used for communcation between 3rd parties for verification purposes)
  • name server record (NS record): url that internet can ping to find out the IP address of the domain (almost always two of them for better reliability)