What is DNS and how does it work?
If you know a thing or two about domain names, you might have seen the letters DNS floating around. Whether in discussion, or in the settings of your website or domain provider, DNS (or, Domain Name System) is an integral part of how the internet functions.
What does DNS stand for?
DNS stands for Domain Name System. In short, DNS is a system which translates domain names – the memorable, human-friendly addresses we type into the search bar – to computer-friendly, numerical (or alpha-numerical) IP addresses.
If you’re wondering what a domain name is, it’s the name of a website plus a domain extension like .com or .co.uk. Domain names are needed to make web addresses easier for people to type and remember, and choosing the right domain name can make or break brand recognition and web traffic. Every website has its own unique domain name, and it also has its own IP address. While domain names are geared towards people, IP addresses are used by web browsers to interact with each other and load internet resources.
DNS is often referred to as a phone book for the internet, as it links a domain’s IP to the domain being searched for – much like linking a phone number to a person’s name. In simple terms, each time a request is made for a specific domain, the DNS looks it up and tells the browser which IP that domain name points to. This process is called DNS resolution, and it allows your web browser to load data from the website you’re searching for.
But it isn’t quite as simple as that, mainly due to the sheer number of IP addresses and domain names out there.
Before DNS
In 1983, Paul Mockapetris invented the Domain Name System. Prior to this, the internet was still in its infancy, and primarily used in an academic capacity. It was essentially limited by the scope of human memory – each separate web page was defined by a 32-bit long IPv4 address, such as 172.16.254.1. Therefore, remembering more than a few addresses was difficult.
Once DNS was implemented, it opened up the internet in a way that was just not possible before. Some of you might be able to rattle off a couple of IP addresses, but chances are you can remember far more domain names – especially those for the most popular websites.
The four types of DNS servers
Before we get into the nitty gritty of how a DNS works, there are four main DNS servers you should be aware of. These servers are vital to the smooth running of the DNS.
Recursive DNS server
This DNS server is responsible for all client machine queries. The recursive DNS server receives these queries via sources such as web browsers, and makes requests on behalf of the user.
Root name server
One of these servers can be expected to answer any queries about domain names directed to the root zone. The root name server will then point these queries in the right direction, usually to the TLD name server.
TLD name server
Depending on which TLD, or top-level domain, has been queried, the appropriate TLD name server will respond. For example if the domain name uses a .co.uk TLD, this is the name server that will be used.
Authoritative DNS server
This server acts as the final locator of the IP address, and if it has access to the requested address, it will ping this over to the recursive DNS.
Now, you might be wondering how all of these components work in unison, let us explain.
How does DNS work?
The system goes through a number of steps to reach the objective of translating a domain to its IP address (DNS resolution). Here’s what it does:
Step 1: The user requests the information
This happens whenever you click a link or enter a URL into your browser, among other things. It’s the browser which makes this initial request. First, it will check its local DNS cache. If you’ve visited a site before recently, its translated address will be stored in the cache so it can be easily found again.
If the address is not in the cache, meaning it hasn’t been visited before or not in a while, the request moves to the next step.
Step 2: The request is sent to recursive DNS servers
The request will be sent up the chain to recursive DNS servers (also known as resolvers). These are provided by the user’s internet service provider, but can also be operated by third party providers such as Google. These have their own caches, and as other users use the same resolvers, popular websites are likely to be stored in this cache.
If the address is found in the recursive DNS servers, the request will be returned to the browser and it will end there. But if it isn’t, it goes even further afield.
Step 3: The root name server directs queries to TLD name servers
The recursive server will query a root name server, which essentially is able to answer questions about domain names. This type of server won’t store any IP addresses itself, but acts as a switchboard – they direct the query to the TLD name servers.
In this case, TLD stands for top-level domain – also known as a domain extension. A TLD name server will contain information for a specific TLD, such as .com, .co.uk, or .net. For instance, if example(dot)com was what the user queried, the request would be directed to a TLD name server for .com domains.
The TLD name server can then direct the request on to the server which stores the IP address for example.com specifically.
Step 4: The TLD server sends the query to authoritative DNS servers
The TLD name server will look at the “example” part of the example.com request, and direct the query to the relevant authoritative DNS server. These are what hold the actual “translations” to the original request. The recursive server – the second step in the process – will retrieve the result of the query and store it in its own cache. If another query comes through for the same domain, the recursive server can now serve the request without having to go through the query process again.
Step 5: Receiving the result
The recursive server will return the answer of the query back to the computer that asked it. In the case of a normal user browsing on their personal computer, the operating system of the computer will then let the browser know what IP address the domain points to – which it can then load.
While there are lots of steps to this process, you wouldn’t notice as you use the internet – as it takes milliseconds to complete each request.
The difference between authoritative and recursive DNS servers
Although they are both types of DNS servers, the authoritative and recursive DNS servers have two different functions. The purpose of an authoritative DNS server is to store DNS records, while the recursive DNS server acts on behalf of the user’s query. Working in conjunction, the recursive DNS server will require information from the authoritative DNS server in order to enact the user's end goal.
Three types of DNS queries
There are three versions of DNS queries: recursive, iterative and non-recursive.
Recursive query
A recursive query deals with DNS client requests via the DNS server. This server will send the appropriate response to the client machine.
Iterative query
In an iterative query, the DNS server will offer the best possible response to the DNS client. However, if there is no response, the DNS client will be provided with a referral address to make the query to.
Non-recursive query
A non-recursive query occurs when a DNS client requests a record from the DNS server and the answer is sent back immediately. No other steps or queries are needed.
Frequently asked questions about DNS
What is DNS caching?
Caching is the process of storing frequently accessed files in a data storage layer called a cache, allowing these files to be retrieved more quickly and easily. For example, browser caching can improve web page load times for previously visited websites by storing web page data on the user’s device, and VPS caching can reduce strain on your server by reducing the number of data requests it has to process.
DNS caching, or DNS cache, enables clients or servers to store their DNS records locally for future use. Ultimately, this avoids re-searching for past DNS queries by storing them temporarily, and the records can be retrieved quicker.
How do I check my DNS?
With Fasthosts web hosting, you can check your DNS records and DNS servers via your Control Panel. To manage DNS for your domain, simply log into your Control Panel, select Domain Names from the Hosting & Domains menu, click on your domain, and then click ‘Configure Advanced DNS’. From here, you can create, edit and remove DNS records.
If you’re having an issue with your DNS resolution/DNS lookup, you can also use a tool called nslookup via Command Prompt to check your DNS records. The nslookup command will retrieve information from the DNS cache of your DNS server relating to your DNS records, domain name and IP address.
What do DNS settings do?
Changing your DNS settings can improve web performance, privacy and security. It may also be necessary if you’ve recently changed hosting provider, as you’ll need to point your domain to the right DNS servers. If you’re a Fasthosts customer, you can change your DNS settings via the Control Panel or contact our support team for help.
If you’re interested in finding out more about what we have to offer, why not chat to our sales team today? Or check out our blog for more interesting articles.