The Domain Name System, or simply DNS, is a naming system used by different devices connected to the Internet. It allows users to connect to different websites using names, for example, google.com. If we didn’t have a Domain Name System, we would need to access websites using IPs, which would be very inconvenient and probably a lot harder to remember.
Thanks to the DNS, our web browsers are able to access different websites by just typing their domain name.
How does DNS work?
But how exactly does this system work? It’s not magic of course, but a complex system of IPs and records. For the DNS to work, we need to things at least: an IP address and a hostname. Each server or device connected to the Internet needs to have an IP address, that’s the way the Internet works, so the IP, in this case, will be used to find the device we’re looking for.
The Domain Name System will have a record stored telling that the site we want to access is hosted on X device. So when we type google.com (or any other domain) or browser will look for the site on the related IP address, not on the entire Internet, and the server behind that IP address will return back the website we want to access once it gets the query from our browser.
Types of DNS servers used while browsing a web page
But like we previously said, this is not magic, but a lot of science, and there’s a lot going in the back that a user won’t see when trying to access a site. There is a total of 4 kinds of DNS servers that play a role when you try to load a site:
The DNS recursor: this is the first server that will receive the query from your browser. It will then redirect your query to the appropriate servers to find the site you’re looking for.
The root nameserver: this server will receive the query from the DNS recursor and start to translate it from human language to machine, that means converting the hostname into an IP address.
The TLD nameserver: in the next step we have the TLD nameserver, which is in charge of searching for a specific IP address, and it will also have the task to host the last portion of the hostname, for example, the “.com” in google.com
The Authoritative nameserver: this is the final step in the query. It will access the record you’re looking for and return back the correct IP, which will be received by the DNS recursor and then sent to your browser. At that moment your browser will know exactly where the website is located and load it up for you after requesting it from the server that hosts it.
What is a DNS resolver?
So, while looking up for a website, your browser will receive an IP address after sending a hostname to the different kinds of DNS server that we previously explained. Between your computer and those servers, there’s a key player: the DNS resolver.
The DNS resolver is actually not outside your computer, but inside of it. It’s a service that runs on your device and stores a database of important DNS name servers, which in turn will be used to connect your computer, smartphone or tablet with the Internet.
If your DNS resolver doesn’t work properly, your device won’t know which DNS servers should reach to get the IP address of the website you want to access, and of course, that means you won’t be able to enter the website you need. If you think the resolver of your device is not working properly, try using, for example, Google Public DNS, which is a fast and secure resolver.
Most home devices already provide a resolver which usually works fine, but if that’s not the case for you, or you want to try a faster resolver, then maybe it’s time for a little change.
Type of DNS records
There are different types of DNS records out there, all of which have different functions and purposes. We won’t explain all of them here because it would take simply too long, but let’s take a look at the most common ones:
- A records: the A records are probably the most important type of DNS records. Thanks to these records, a hostname can be related to an IP address. If there were no A records, then the resolvers just wouldn’t know where to look when you tell me to access a certain website.
- MX records: these records are used for mailing purposes. Also called mail exchanger records, they tell which servers are responsible and have the authority to receive an email in the name of the recipient’s domain. The server then will move the received email to the users’ inbox of course.
- CNAME records: also known as a canonical record, a CNAME is used to tell that a domain name is acting as an alias of another domain. It is used to point different records to the same destination, for example, an FTP record and an MX record pointing to the same domain’s A record. Then, if the domain’s IP changes, we won’t need to change the FTP and MX records, because they’re an alias of the domain and will point to the same IP.
- TXT records: these records are used to display different kinds of data, for example, they’re used to specify records like SPF and DKIM, which in turn are used by emails server to know which server is authorized the send emails in behalf of a domain.
Check out the following video if you need more details: