DNS: Understanding How the Internet's "Address Book" Works

DNS: Understanding How the Internet's "Address Book" Works

DNS is an essential part of the Internet, and it plays a vital role in making the Internet work

Humans have always relied on names for identification and subsequent communication throughout history. Similarly, computers have their way of connecting and talking to each other within a network—they use numbers. Just as we call each other by name, computers use numbers (IP addresses) to identify themselves and exchange information over a network.

Network engineers developed DNS (Domain Name System) to bridge the communication gap between computers and humans. DNS acts as a translator, converting the domain names we are familiar with, like "www.amazon.com", into the corresponding IP address that computers understand.

In this article, we will explore what DNS is, and how it translates domain names into IP addresses, DNS hierarchy, and DNS record types. This knowledge is valuable for understanding the internet's infrastructure and is helpful for networking, cybersecurity, and web development.

Prerequisites

What is DNS?

When searching for information in a phonebook, I'm pretty sure you search for a name first and then find the corresponding phone number. DNS can be likened to a phonebook—but for the internet. People who search for information online typically use domain names because they are easier to remember. In the case of computers, they only understand numbers, so, DNS serves the purpose of converting these domain names into IP addresses. This conversion enables computers to communicate effectively with each other over a network.

DNS Lookup

You're writing code and run into a bug, so you decide to turn to the vast knowledge base of Stackoverflow for a solution to your problem. Opening your web browser, you eagerly type the URL into the address bar and hit enter.

What happens behind the scenes? Let's find out.

When you hit the enter key, your browser springs into action and checks its cache—a temporary storage that holds frequently accessed data—to see if it already has the IP address associated with the domain name you entered. If the IP address is found in the cache, the browser retrieves it and displays the page, saving time and boosting performance. However, if the IP address is not cached, the browser sends the request to the next level, the resolver server. The resolver server is operated by your internet service provider (ISP).

Navigating the Request

Upon receiving the request, the resolver checks its cached memory for the IP address. If the IP address is not found, the resolver forwards the request to the next level in the hierarchy, known as the root server. Root servers sit at the top of the DNS hierarchy.

There is a common misconception that there are only 13 root servers, but this is incorrect. Note: In reality, there are numerous root servers in existence but they all share the same 13 IP addresses. This limitation is a result of how the Internet was designed in its early days, which set the maximum number of root servers at 13. As the Internet has expanded over time, additional root servers have been introduced to manage the higher volume of traffic.

When the root server receives a request for the IP address, it does not have the answer itself, but it knows where to direct the resolver to find the answer. The root server's job is to point the resolver in the right direction so that it can locate the IP address. This is a classic "I know a guy, that knows a guy that knows a guy" scenario.

The Journey continues

The root server directs the resolver to the top-level domain (TLD) server, which is responsible for storing the address information for top-level domains such as .ORG, .NET, .COM, etc.

The resolver is then directed to the specific TLD server that manages the .com domain which Stackoverflow.com is a part of. When the request for the IP address of StackOverflow.com reaches the TLD server for the .com domain, it does not have the answer, so it redirects the resolver to the authoritative name server which is the final authority.

The Final Stop on the DNS Journey

The authoritative name server knows everything about a domain, including its IP address. It returns the IP address to the resolver, which then returns it to the web browser. The web browser can then connect to the StackOverflow website.

Note: The resolver stores the IP address in its cache memory after it receives it. This prevents the resolver from having to go through the same steps again the next time a user requests the same domain name. This improves performance by reducing load time.

DNS Records

The authoritative name server resolves domain names to IP addresses using DNS records, which are stored in something called zone files. A zone file is a text file that contains all of the DNS records for the domain. There are numerous DNS records, but I'll only talk about a few of them briefly:

  • A (address) record: They resolve a domain name into an IP version 4 address (IPv4), A record is the most common DNS record.

  • AAAA record (pronounced as Quad-A record): They do the same thing as an A record, the difference being that it converts domain names to IPv6 addresses.

  • CName (canonical name) record: It resolves a domain name or subdomain name to another name. For example, you could use a CNAME record to point the domain name www.stackoverflow.com to the domain name stackoverflow.com, this would allow you to access the same website using either domain name. Try to access StackOverflow using both domain names and see for yourself.

  • MX (mail exchanger) record: This record is used for emails. It points to the server where an email should be delivered for a particular domain name.

  • Txt (text) record: This type of DNS record can store a variety of information, such as website keywords, security information, and general or contact info.

    For further reading on the other types of DNS Records, check out this article

Conclusion

By understanding how DNS works, you can better appreciate the technology that makes the Internet possible. The entire process of a DNS lookup is usually completed in a fraction of a second, and users are generally unaware of the complex steps that take place behind the scenes. Now that you know how DNS works, go forth and use your knowledge to impress your friends and family. Or, you know, just use it to get to your favorite websites. See you next time!

Credits:

  • Meme (Google).