How is a DNS Similar to a Phone Book?

The Domain Name System, or DNS, is often compared to a phone book for the internet. It maps human-readable URLs or hostnames like www.fireship.io to the IP address of the server that hosts that site.

When a URL is typed into a browser, a DNS query is made to figure out which unique IP address is associated with that hostname. It first attempts to look in the local browser or operating system cache, but if the cache is empty, it needs to look up the IP address in the phone book, which is the job of a server known as the DNS recursive resolver.

The DNS recursive resolver is recursive because it needs to make multiple requests to other servers, starting with the root name server, which itself will respond with the address of a top-level domain DNS server that stores data about top-level domains like .com or .io. The resolver makes a request there, which will respond with the IP address of the authoritative name server that contains the requested website’s IP address. That gets sent back down to the client and is cached for future use.

Although it may sound complicated, this all happens within a fraction of a second. The DNS can be thought of as a globally distributed database that handles more requests than any other database in the world.

When you register a domain name, it’s handled by a registrar accredited by the non-profit organization ICANN. The record is then maintained by a registry operator who stores your DNS settings and propagates them to other DNS servers around the world. As the registrant, you’ll be assigned a zone file where you can configure the settings of your domain. Every zone has a startup authority record to tell other DNS servers who’s in charge of that domain.

Most importantly, we have the A record, which means address and maps a domain or subdomain to the IP address of its host. In other cases, though, we may want to forward a domain to another domain on the internet instead of an IP address, in which case a canonical name or CNAME record would be used. We have MX records for email, and we can store arbitrary data with text records, which is often used to communicate with third parties to verify ownership of the domain.

Finally, we have the NS or name server record, a URL that the internet can ping to find our IP address, and there’s almost always two of them for better reliability.

In conclusion, the DNS plays a crucial role in connecting human-readable URLs to their corresponding IP addresses. It’s a globally distributed database that handles more requests than any other database in the world. The DNS can be complicated, but it’s an essential part of how we access websites on the internet.