Domain Name Servers (DNS) is a critical service that is part of every network and website in the world. DNS is crucial to how internet functions and allows your computer to find and access other computers and services across the world!
If you have ever visited a website or sent an email, you are using DNS! In most cases, it just works!
What is DNS?
DNS is like the Postal address system for the internet and local networks. For example, if you want to visit Twitter on your PC, you would type in Twitter.com in your favorite browser and will be almost instantly connected to Twitter's website.
How does your computer know that when you type in Twitter.com to take you to the right computer and server out of the millions across the world?
When you send emails, how does your computer know where the recipient is?
When you want to print to your wireless printer, how does your computer know where to send the print job?
The answer is DNS
Analogy - Postal System
Imagine you are sending a letter in the mail from your house in Seattle, WA to your friend in Nashville, TN 📬. When you mail that letter, your letter is carried by the postman back to the mail facility, it is then sent out with the rest of the outgoing mail to a sorting facility. These letters are then sorted and transferred to the next station, this happens multiple times until your letter finally arrives at your friends city. Your letter then is handed to a mail carrier who will bring it to your house. This whole process takes a matter of days. You don't have to understand how the layers of the postal routing system work to mail your letter and you can rest assured that it will reach the right place.
This same philosophy applies when you are visiting a website. You type in the name of a service you wish to visit such as Twitter.com. Your computer makes a connection behind the scenes to your Router, your Modem, then your Internet Service Provider, then a root name server to determine which server has the address information, then another request is made to the root hint server to get the actual IP address of the service. This serve has the address in the form of an IP address which is a series of numbers.
At this point, DNS has finished it's job and got the final address of the destination, routing kicks in and your computer makes a connection to the IP address that it received, your computer is connected to this numerical address behind the scenes where computer will perform a Get request to the web server and request the content on that server which you will see in your browser.
As an example, one of the IP addresses that resolves from Twitter.com is 220.127.116.11. Could you imagine having to memorize the IP address number for each website that you wanted to visit?
Say you wanted to go to Facebook.com but you had to know the IP of 18.104.22.168, you could open your browser and type in http://22.214.171.124 and it would connect you to Facebook.com (go ahead, try it!).
Your computer makes several connections behind the scenes when you visit a website, and all of this happens almost instantly. The very first time you access a website, your computer has to load all of the content but it saves the DNS information, route information, and some of the content in various caches on your computer so that subsequent requests happen much faster. In the below example. you can see what is called a trace report showing that there was 15 separate connections that it took to reach my website! It's incredible that all of this happens magically in the background for you.
Email uses DNS
Email 📧 is the electronic version of a letter that we use to mail. Thankfully this service also uses DNS to route your email and ensure that it ends up in the right mailbox. It takes a similar journey as your physical mailed letter. Have you ever sent an email and received back a Postmaster rejection error that your email wasn't delivered? That's the same as getting a returned letter in the mail.
Business Networks use DNS
All business networks use DNS the same way that the internet does for finding information. For example. if your company has a central file storage where you may save or access information. Your computer uses DNS to find the server that has the requested information and then connects your computer to that server or resource and provides the information.
We can thank Paul Mockapetris (@svnr2000) for the invention of DNS and the fact that we don't have to remember these IP addresses to visit the websites that services that we use every day. Source: Internet Hall Of Fame
DNS Record Types
DNS also handles the routing for everything with the domain name using different types of records. Every domain has DNS settings, which is how root hint servers get their information for your website. These settings can route your website, your email, sub-domains, and multiple other services. Some of the most common ones are listed below along with the services that they are used for.
- A Record - This is used to tell DNS root servers the IP address for your domain.
- C Name Record - This is used for subdomains. Say you own example.com but you also want to have blog.example.com. the "blog" portion of this address is a CName record which can point this part of the website to a different IP address in the event your blog is hosted somewhere other than your website. I use this for my own domain (chrisbenjamin.dev and blog.chrisbenjamin.dev)
- MX Record - This is used for mail routing. When someone sends you an email to your domain such as (email@example.com) then DNS is used by the email servers to determine where to send that email
- TXT Record - Text record, typically used for administrative notes, validation, or other security features for the domain.
- NS Record - Name Server Record lets DNS servers know which server is responsible for resolving records on your domain name.
You can check out DNS information for any website, it's all publicly accessible information. You can use built in tools on your computer such as nslookup to find information from a command line, but if you prefer the graphical approach then my recommendation is MXToolbox SuperTool available here. You can use the drop down to search through all available records for a domain and see what you can learn!
Changing DNS Records
When a DNS record is changed, such as moving your website from one hosting provider to another, or simply adding a new C Name record for your blog site. These changes go through a process called propagation. During this time, many DNS root servers will still be pointing to old records because of DNS caching, or may not have the record yet. This process can take up to 72 hours to propagate around the whole world so it's important to plan your changes wisely. Some servers will pick up the change as soon as 5 minutes, while others will take several hours.
When DNS problems occur, there is usually a failure along one of the many paths that the computer uses to resolve the domain name. When troubleshooting DNS it's best to follow the chain and see where the problem occurs. There are numerous errors caused by DNS since it's the heart of almost all network communication between computers and servers around the world.
My goal was for you to learn at least one thing new in this article regarding DNS. This article has covered some of the basics of what DNS is, why it's important, the basic principals of how it works, and how to check DNS records yourself. If you are a web developer, spend some time familiarizing yourself with DNS if you are not conformable with it, it will be important when it comes time to deploying your website on the internet.
I’m on @buymeacoffee. If you like my work, you can buy me a taco and share your thoughts 🎉🌮