What is a DNS Server?
You may have come across the term “DNS server” before but weren’t sure what it referred to. This article aims to answer the question what is a DNS server as well as explain how they work. A DNS, short for domain name system, is used to resolve a particular domain name to its IP equivalent. Domain names (e.g. keycdn.com) are simply used to be more easily read / remembered by humans, however, all domain names are associated with a particular IP address. This can be compared to a phonebook where a person’s name would correspond to the domain name (e.g. yourwebsite.com) and their phone number would correspond to the website’s IP (e.g. 159.x.x.x).
These IP address lookups are performed by DNS servers. A website address is associated with a particular DNS hosting provider’s name servers which are responsible for resolving the IP address of said website. The actual process of how a DNS server works is explained in greater detail in the section below.
How Does a DNS Server Work?
You can perform a DNS lookup using a couple of methods such as using
dig example.com in the CLI or using a DNS lookup tool. There are a few steps that take place when a DNS server is asked to lookup a website’s IP.
- Website Request - The first step is, of course, to request the actual website via a web browser. When someone types in a particular website’s address (e.g. keycdn.com) into their address bar, the DNS lookup process begins. Both the OS and browser first look at their own DNS caches to see if the information is already stored locally. If not, the resolver must be asked.
- Ask resolver - Once the locally cached DNS records have been checked, the OS asks the resolver. The resolver is usually your ISP (internet service provider). It first checks its own cache to verify if the information is not already stored locally. If it’s not, it goes on to ask the root server.
- Ask root server - The next step is to ask the root server. The root server looks at the last section of the request (the .com portion). Although the root server cannot locate the IP address of the website, it tells the resolver where the top level domain (TLD) servers are for .com. The resolver then stores this information for later use.
- Ask TLD server - The resolver goes on to ask the TLD servers the IP address of the website in question. Although the TLD servers can’t provide us with the required information, they know where to direct our request. The TLD servers provide the resolver with a list of name servers for that website. Again, the resolver stores this information for later use.
- Ask authoritative name servers - Finally, now that the resolver knows what the authoritative name servers are, it can query these name servers and retrieve the required IP information. The authoritative name servers contain all the necessary information regarding a particular domain.
- Cache the IP and return it to the browser - Now that the resolver knows the IP of said domain, it will cache it for later use. At this point, the IP is delivered to your OS where it is locally cached as well. The OS then passes this information on to the browser. Once the browser knows the IP address of the website, it can then begin requesting and receiving information from the website’s origin server.
Choosing a DNS Hosting Provider
If you’re setting up a website, it is important to choose a reliable DNS hosting provider. A DNS hosting provider is responsible for providing the authoritative name servers as mentioned in step 5 above (e.g. ns1.yourdomain.com, ns2.yourdomain.com, etc). These name servers are able to provide all necessary information regarding your website. Choosing a reliable DNS hosting provider is important for a few reasons including:
Setting up a backup DNS provider is important to avoid downtime in the event that your primary provider goes down. Redundancy will help ensure that your website remains live, which is crucial for many online businesses. Speed is also important as a good DNS provider will ensure that latency between DNS lookups and TTFB is minimal. Lastly, as long as you have implemented proper redundancy, this will also help increase security in the event of a DDoS attack.
To learn more about DNS hosting providers, check out our 10 Best Free DNS Hosting Providers article.
What is a DNS Server - In Summary
Hopefully this post has helped clarify the question “what is a DNS server” as well as provide some insight into how a DNS server works. DNS servers are an essential aspect of how the Internet functions. Without DNS servers, there would be no way to associate a particular domain name to an IP.
It is also important to note that if you are hosting a website, choosing a reliable DNS Hosting Provider is vital for a few reasons - mentioned in the previous section. Additionally, if you are looking to optimize your website’s current DNS lookups, consider reading our Reduce DNS Lookups post.