What are A, CNAME, MX, TXT, and other DNS records?
Ever tried setting up your DNS cleanly for the first time by following a tutorial you stumbled across online – you follow all the directions you're given, but still, nothing seems to work?
This happens. And without a proper understanding of DNS and how it works, online folks are left with no option but to consider guess-editing. They end up trying everything suggested to them and wait for DNS to propagate itself to test the suggestion.
To better understand DNS and all of its operations it's best to think of it as the internet's phonebook. It's what powers the internet. Or as someone else would say, the cloud itself is built around DNS.
A simple analogy
In this analogy the cloud is your cell phone. In the cell phone you have a contact list. Every time you want to call someone, you browse through your list of contacts to find their name. You then proceed to dial up that name, and the phone automatically dials their number.
In other words, you're using the easiest piece of information you can remember to locate someone's phone number so you can call them. This saves you the trouble of having to memorise their phone number.
The Domain Name System or DNS appears to function pretty much the same. Where your phone's contact list contains a list of names of the people you contact from time to time, together with their phone number and other contact details, the Domain system has a list of similar associations, called DNS records.
So for this analogy, the name of a contact is comparable to a domain name, while their actual phone number is the I.P. address mapped by that particular domain name, in which case, it's a whole lot easier for online users to remember your domain name than it is for them to remember its corresponding IP address.
It's worth noting that a domain name is nothing more than a text-based identifier for an IP address. Which is to say, if people remember numbers better than text, then there would be no use for them.
Let's use Google as an example.
People know Google as the world's biggest search engine. So every time someone feels like querying something on this search engine, they simply type google.com into their address bar.
So your browser, like your cell phone, will look up google.com and pull up its IP address before proceeding to connect. In so doing, you are connected to google.com, just like you requested. But unbeknownst to you, you were connected to the IP address: 172.217.12.206.
Types of DNS records
Now that we've likened DNS to your phonebook, let's zoom in to DNS records. While adding a new number in your contact list, what you'll be doing is saving the number of that particular contact under their name. But that's not all you're allowed to do. You could also save their email address, another phone number they use, or some little bit of text detailing your association.
All the information you save under someone's name in your phone book is the equivalent of DNS records online.
Quite differently, an IP address is not the only record that can be saved under a domain name. There's a string of other records, and that's what you're about to learn by reading the rest of this article.
Address record (A record)
This is your web host's address. It's the equivalent of a phone number.
Each domain name is linked to one of these numbers. It's what tells browsers where to find the underlying host of any website on the web. It's the address that browsers use to find what a user has requested from their address bar.
So every time you migrate your website to a different host, this address changes. Meaning, you have to go back to the A record and update it.
Read this bearing in mind that there are two versions of IP addresses in use at present – and that is, IP address version 4 (IPv4) and IP address version 6 (IPV6). Speaking of which, A Records are only restricted to mapping IPv4.
IPv4 is the traditional version of IP addresses, and will soon be phased out. This address uses a 32-bit address scheme, which can only create a total of 4 billion addresses. That's to say, as the internet grows, the demand for IP addresses may far surpass the address supply.
In response to this, Internet Protocol version 6 (IPV6) was created. Also referred to as Internet Protocol Next Generation (IPng), these IP addresses use the 128-bit binary system.
Here's the difference between the 32-bit and 128-bit numeric system of numbers. With 32 bit, your IP address is written in four sets of numbers separated by periods. Each number ranges from 0 to 255. It can be anything like 202.170.56.340.
128-bit, on the other hand, allows your IP address to be written in hexadecimal and separated by a colon. So you end up with an IP address that looks like this:
3ffe:1800:4545:3:200:f8ff:fe21:67cf.
A records can only take IPv4 addresses as their value – and not very different from attaching different numbers to the same name, it's possible to point multiple or several IP addresses to the same domain name. All you have to do is create another A record, but with a different IPv4 address, and point them to the same domain.
That leads us to the Next DNS record:
The AAAA record or quad-A record
So while the A record maps IPv4 addresses, AAAA records map IPv6 addresses. People use A record and quad-A records interchangeably, but they're not the same thing.
They both map IP addresses, but the difference comes with the version of IP addresses they map.
A quad-A record can only take IPv6 addresses as their value. And as with A-records, it's also possible to point multiple or several IPv6 addresses to the same domain name. Again, all you have to do is create another quad-A record with the same name, but with a different IPv6 address, and point it to the same domain name.
Canonical name record (CNAME record)
This DNS record operates as an alias. It specifies that a particular domain name is an a.k.a. for another domain name.
A common example is a "www" CNAME record. So if your website is 1234567.com, adding "www" before it (www.1234567.com) doesn't make it a different website.
A CNAME is used when you have different variations of the same domain name pointing to the same IP address.
A CNAME record can also be used when you have a blog or webpage that's hosted on a different server than the rest of your website. That means the blog is operating with a different IP address.
CNAME allows you to create a variation of your website. So you have your website pointing to one website and the blog or any other webpage you have created pointing to another.
Mail exchange record (MX Record)
This is a record that points to where your email is hosted. It's the record responsible for associating your domain name with an email server. And typically, one domain name can have more than one MX record.
For instance, you may decide to use Google as your email host. And if this is the case, your MX records will be pointing at Google's email servers.
With MX records, providers know where to route an email that's directed your way. Say you're sending an email from outlook.com. Outlook will run a DNS lookup to find where your emails are hosted. Your email takes the usual form of user@1234567.com. So outlook picks it from there and knows where to send your message.
TXT record (text record)
TXT records are typically used for verification of a domain name, or implementing the Sender Policy Framework (SPF), and detecting forged use of domain names (for spam, phishing etc.)
SRV record
This record specifies the server by both hostname and port number. It's the record that makes it possible to discover a server so you can designate high-availability and high-priority servers with a single domain without knowing their exact addresses.
So, any web application that needs to find out where a specific server is located can initiate a query for the corresponding SRV record describing the server, including its location.
SRV records have a distinctive naming system. First, there's an underscore, which is followed by the name of the service or server. This will then be followed by a full stop and an underscore, followed by a protocol, another full stop, and lastly the domain name.
So you end up with something that looks like this:
__http.tcp.example-1.com
In conclusion
DNS records can be tricky. We hope this article helps shed some light on what each is for. If you're still struggling with the concepts you can always ask your domain registrar or web host to help you set them up. it could save you a lot of time and frustration.