The Ins and Outs of DNS: A Technical Guide
Everything a software developer should know about how the domain name system works.
Hi Friends,
Welcome to the 109th issue of the Polymathic Engineer newsletter.
This week, we discuss one of the most essential pieces of the internet infrastructure: the domain name system. The outline of the first part is as follows:
What is DNS?
Why do developers need to know how DNS works?
DNS Server Hierarchy
How the DNS lookup works
Caching and Propagation
DNS records and Services
Advanced Functionalities
Security
What is DNS?
In one of the previous articles, we have seen how two processes running on different machines can reliably communicate using the TCP protocol. However, to create a new connection with a remote process, it is first necessary to discover the IP address of the computer where it runs.
The most usual way to do that is through the Domain Name System. The DNS is like the internet's address book since it changes human-readable website names into IP addresses that computers can understand.
Think about what it would be like trying to browse the internet by typing in strings of numbers like 172.217.16.206 to reach Google, or 208.80.152.2 to access Wikipedia.
Without DNS, people would need to remember complicated number names to access websites and services. Instead, we can use easy-to-remember names while DNS finds the matching IP numbers.
However, DNS is more than just a basic lookup service. It's a distributed, hierarchical, and eventually consistent system designed to be robust, scalable, and responsive. This ensures that users can access websites and other services quickly and reliably.
This article will explore how DNS works to give you an idea of how DNS handles all these requirements and will come in handy if you're ever unlucky enough to have to troubleshoot DNS problems.
Why knowing how DNS works is important
Before going into technical details, I want to spend a few words on why it's important for developers to understand how DNS works.
First, if you build and deploy applications, you'll usually need to set up and take care of your DNS infrastructure. This may include directing users to your load balancers or servers, checking the health of these servers to see which ones can handle traffic, or using geolocation to send users to the closest server.
Popular DNS systems like AWS Route 53 have helpful features that can significantly boost your application's performance and reliability if you know how to use them well.
Second, DNS errors can lead to challenging and widespread outages. While a bug in your application logic might crash a server or degrade the user experience, a DNS misconfiguration can bring down your entire site. Many big companies like Notion, Google, Slack, and others have experienced prolonged outages due to DNS errors.
If you need to find out why a service isn't working or look into weird network issues, knowing about DNS can help you solve the problem faster.
Finally, hackers often target DNS, so keeping it secure is very important. For example, if someone tricks your DNS system, they could send people to fake websites that look like yours. This results in stolen information, scams, or reputation damages. Knowing how DNS works lets you implement proper security measures and recognize potential threats.
DNS Server Hierarchy
The Domain Name System is implemented as an application layer service which runs on servers that sit at the network edge. The servers are organized in a hierarchy where each level is responsible for a specific part of the name resolution process.
At the top of the hierarchy are the root servers. These are the first point of contact in the DNS resolution process. There are 13 logical root servers around the world. Each logical server is replicated across thousands of physical servers for availability and performance.