Weeks ago when we started this Web Hosting dictionary, we started explaining what is DNS, and we found that the DNS service is the heart of the modern internet. Later we described what was a DNS zone, and today we will check what is a DNS record, and the types of DNS records that actually exists.
What is a DNS record?
DNS records are used to map each website dns configuration so the DNS server knows which IP address is associated with each record. That way it can handle all the incoming requests for each domain.
When you visit microsoft.com for example, you are sending a request to the DNS server, then the DNS server will search for the type of DNS record that you are requesting, it could be an A, CNAME, TXT, NS, MX or PTR record.
Another example, when you send an email, your email server will have to know the MX record of the final domain you are sending to. Following microsoft.com example, let’s see what is the MX record for their email server:
[webtech@localhost ~]$ dig MX microsoft.com ; <<>> DiG 9.10.4-P6-RedHat-9.10.4-4.P6.fc25 <<>> MX microsoft.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62469 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 9 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 512 ;; QUESTION SECTION: ;microsoft.com. IN MX ;; ANSWER SECTION: microsoft.com. 3600 IN MX 10 microsoft-com.mail.protection.outlook.com. ... ... ...
As you see, it’s easy to get a remote domain dns record if you need it. However, this is just an example, let’s see the full list of type of dns records, and what are they useful to.
Types of DNS records
There are lof of types of DNS records, let’s explain each one of them brevfly:
- A records
- AAAA records
- CNAME records
- NS records
- MX records
- PTR records
- TXT records
- A records
Address (A) records are used to map hostnames to numeric IP address. For example, nixcp.com has an A record pointing to XX.XX.XX.XXX IP address.
Another address (A) record is setup for www.nixcp.com subdomain, pointing to the same address.
But we could also setup another A record called blog, this can point to another IP if I decide to host the blog on a external server for example.
This type of records looks like:
nixcp.com. 1800 IN A 22.214.171.124
The AAAA record is pretty much the same as the A record, the only difference is that it is used for ipv6 addresses, instead of ipv4.
MX records allow multiple records to be used, same as Google Apps uses their MX setup when you purchase a mail account, for example:
domain.com. 3.600 MX 1 ASPMX.L.GOOGLE.COM domain.com. 3.600 MX 5 ALT1.ASPMX.L.GOOGLE.COM domain.com. 3.600 MX 5 ALT2.ASPMX.L.GOOGLE.COM domain.com. 3.600 MX 10 ALT3.ASPMX.L.GOOGLE.COM domain.com. 3.600 MX 10 ALT4.ASPMX.L.GOOGLE.COM
MX (mail exchanger) records allow you to send and receive email messages.
CNAME means Canonical Name, and it is used to create alias of another record.
For example, you have an A root record for your main domain domain.com pointing to XX.XX.XX.XX IP.
Then, you create a CNAME for www.domain.com subdomain, this CNAME will be an alias of your current A record, and it will show the same information.
NS means “NameServer” and it is a type of records used to specify the authoritative nameservers for the domain, for example:
yourdomain.com NS ns1.yourdns.com. yourdomain.com NS ns2.yourdns.com.
PTR records (pointer records) are used for reverse lookups. For example, if I want to resolve 192.168.1.110 to www.yourdomain.com, the record would be:
126.96.36.199.in-addr.arpa PTR www.yourdomain.com.
This type of records are also called rDNS, and are used often when you have your own dedicated IP address in a shared hosting environment or a dedicated/vps/cloud server.
A TXT record is used to host text-based information, most common TXT records are used to store SPF (sender policy framework) information, it’s a way to prevent spam and mark mails as trusted from various email providers. TXT records looks like:
yoursite.com. 1800 IN TXT "yandex-verification: 5987d3c0a4384"
This is an example of the type of TXT record used by Yandex for their stats system.
As you see, the DNS system is really tricky, one of the most complicated things to learn when you are starting in the web develpment and system administration world. There are lot of types of DNS servers, lot of type of records, and many ways to use each and every one of them.
It may looks simple as it was explained here, but mixing all the DNS, domain registrar, name servers, type of records, and everything around it takes time and experience to really understand how it works, and even more to troubleshoot DNS errors when they appear.