You’re probably already familiar with DNS records and their usage, but many people out there, especially those new to the hosting industry, have trouble finding their way around them.
This article is primarily curated for those people, so follow along with us as we explain the concepts and the various types of DNS records, and how they work. We will try to explain the ideas as simple as possible.
Before we dive in, let’s first quickly review the idea of the domain name itself, and how it operates? Well, every domain name on the web, is meant to make it easy for us to reach destinations of various websites on the internet, in other words, websites are present on computers connected to each other via the Internet, but they communicate using numeric addresses (IP addresses) which are very difficult to memorize, so by using a domain, it will make it so much easy to reach those destinations, as it links each website with the corresponding IP address of the respective server that’s hosting it.
So for our demo website (demo.wevrlabs.net) for example, the corresponding IP address would be 188.8.131.52 … To learn more about this topic, read our article on domain names:
Now, this brings us to our main topic today, how does this link between domains and their IP addresses work? and the answer is: Via DNS Records!
What Are DNS Records?
DNS Records are a set of instructions that tell the browser from which location to serve requests for a domain name. These records combined together are commonly referred to as the DNS Zone, and would normally be stored on a server called the Authoritative DNS Server, which stores and manages the values for each record in the zone, and then, values are populated throughout the Internet for other DNS servers in the DNS system hierarchy to be cached and served for end visitors, part of which is your ISP DNS Servers.
How DNS Records Work?
As simply as possible, a DNS record will tell the location from where to serve a particular request (it could be any type of request, such as HTTP, mail sending, etc), so for our demo website (demo.wevrlabs.net), the DNS record in the zone will return the corresponding IP for the server hosting it (184.108.40.206), this is called an A record and its function is to tell which IPv4 address the domain is linked to. We will review the most common types of DNS records down below in a bit.
This process of mapping domain names to their IP addresses starts by firstly specifying the place where your domain’s DNS Records (DNS Zone) are managed (i.e: the Authorative DNS Server) since every domain in the existence needs this.
If you are new to web hosting, you’d probably already starting to form an idea at this point of how this works, if you recall, back when you registered your domain and setup hosting for it, you were asked to provide a “Name Server/Servers” during the domain ordering steps. These name servers in most cases were already entered by your hosting provider, which means that your domain’s DNS Zone is now managed by the same server you are hosting the website on, and this is the most common approach in general, where hosting provider would take care of providing a place for storing and controlling records of the DNS Zone (commonly via cPanel).
But your domain DNS Zone doesn’t necessarily have to be managed by the same server on which you are hosting the website, in fact, we always recommend that domain DNS records be managed by a separate DNS service provider (ideally Cloudflare). Why? well, for a start, it is much more reliable and it will make it very easy to switch hosts (or servers) in the future, as you wouldn’t have to replicate the majority of the DNS records for your domain on the new provider’s servers.
To read more about the specifics of how DNS system works, visit our article on domains:
DNS records are stored in the DNS Zone file in the form of pairs, the simplest form of it looks something like below:
$ORIGIN wevrlabs.net. $TTL 1h wevrlabs.net. IN A 220.127.116.11 www IN CNAME wevrlabs.net demo IN A 18.104.22.168 blog IN CNAME wevrlabs.net go IN CNAME cname.bitly.com @ IN MX 10 aspmx1.migadu.com
Of course, you wouldn’t have to worry much about this, since you’re probably will be given an interface to manage and modify these records in a more friendly human-readable way. For example, Cloudflare’s DNS settings section looks like this:
While the view from cPanel is something like this:
Types of DNS Records
There’re many types of records in the DNS Zone file as you can see above, each serves a particular purpose. Below, we’ll explore the most common ones.
A and AAAA Records:
the A record is one of the most common and main records in the DNS Zone file, it accepts the numeric value of the IPv4 address format. It directly tells the browser where to go for serving the content of the website. AAAA is the same, only it accepts the alphanumeric value of IPv6 addresses. So from our DNS Zone file, the format can be read as something like:
[name] points to [IPv4 address]
Where “name” is the domain (eg. wevrlabs.net) and “IPv4 address” is the corresponding server IPv4 (eg: 22.214.171.124). So it becomes:
Short for “Canonical Name”, the second most common record in the zone, but unlike the above types, it accepts string values and maps a domain to an alphanumeric value of a hostname target instead of IP. For example, the canonical name for “www.wevrlabs.net” is “wevrlabs.net”. This can be read as:
[name] is an alias of [target]
CNAMEs are commonly used instead of “A” records, to point domains that share the same IP destination in the zone, this can save time when there’s a need to change that IP in the future since you only just need to update the A record for the root domain.
So for example, this CNAME record above tells the browser that requests for “www.wevrlabs.net” are handled via “wevrlabs.net” which in turn have an “A” record of 126.96.36.199, so the final destination of the request will reach the server on the IP address above.
The MX Record is the one responsible for telling mail clients the server in charge of handling email communications sent to the different email addresses of the domain (for example, [email protected]). It has an extra value called “Priority” which determines the order of the servers that handle emails, for instance, server “aspmx1.migadu.com” for our domain has a priority of 10 while “aspmx1.migadu.com” has a priority of 20, this means if the connection to the first server fails, the mail client will try to communicate with the next MX server in the zone file.
The TXT Record stores content in the form of text values for the domain. This is used to communicate data for particular purposes, most commonly such as domain verifications. In the DNS Zone file, the format can be read as:
[name] has a record with content [content]
Where name is the domain (or subdomain) and content is the value. Becomes:
We hope that by now you have formed a good idea about DNS Records, their types, and usage, and of course, if you have any thoughts in mind, feel free to share with us on the comments section down below.