In my last post in this series I talked about authoritative nameservers and what they do. Their function is responding to queries for domain names they are authoritative for. These queries are for specific record types; in this post I will be talking about common record types you will encounter in your use of the DNS.
For the sake of simplicity and ease of understanding I’m limiting this post to the most common record types i.e records you are most likely to encounter and use in your day-to-day use of the DNS. These are not all the record types that are available for use in the DNS.
Let’s get started.
A and AAAA records
A records are what is known as a “address record” type, that is they return a IP address. For the case of A records they specifically return a IPv4 address.
AAAA records serve a similar purpose, they are just for IPv6 addresses instead.
Here is an example of both:
% dig +short nullrouted.space A 188.8.131.52 % dig +short nullrouted.space AAAA 2600:3c03::f03c:91ff:fee7:9cd3
A couple things about the above dig commands:
- +short tells dig to only show us the answer to our query without all the additional verbose output that dig has returned (for example in my previous posts)
- You will notice I specified the record type I wanted after the hostname. By default, if you do not specify a record type dig will query for the A record. So this means if you want to query for any other record type other than an A record with dig, you will need to specify the record type. We will be using this method of query for the other record types in this post as well.
A records can only contain valid IPv4 addresses. AAAA records can only contain valid IPv6 addresses. A DNS name can contain multiple A and/or AAAA records.
CNAME or Canonical Name record is a record types that maps one name (an alias) to another (the canonical name).
Let me use an example of three queries to demonstrate:
% dig +short wiki.tenforward.social CNAME erlking.asininetech.net. % dig +short wiki.tenforward.social A erlking.asininetech.net. 184.108.40.206 % dig +short wiki.tenforward.social AAAA erlking.asininetech.net. 2600:3c03::f03c:91ff:fee7:9cd3
In this example, the name wiki.tenforward.social has a CNAME for erlking.asininetech.net. This means that when a resolver queries for wiki.tenforward.social, it will get pointed at erlking.asininetech.net which it will then need to resolve further to get to the final answers, which in our case our are for the A and AAAA records.
CNAME records are helpful in cases such as when you have a number of sub-domain records all pointing to the same host. Instead of using A/AAAA records for each sub-domain, using a CNAME means you only need to modify the A/AAAA record for the target of the CNAME if the IP addresses change instead of modifying a bunch of A/AAAA records.
CNAMEs come with some restrictions in their use:
- CNAMEs must always point to another domain name, not an IP address.
- If a name has a CNAME, it cannot have other record types, so like in our example since wiki.tenforward.social has a CNAME record, it cannot also have an A/AAAA record.
- CNAMEs cannot exist at the apex of the DNS zone, that is if your domain is example.com, the name example.com itself cannot be a CNAME record.
- MX and NS records cannot point to a CNAME record (RFC 2181 section 10.3).
MX records (Mail eXchanger) are used to specify the mail server responsible for receiving email for a domain name.
Let me demonstrate with an example:
% dig +short nullrouted.space MX 20 in2-smtp.messagingengine.com. 10 in1-smtp.messagingengine.com.
There are two components to a MX record, the first is the preference value (usually called “priority”), in our case we have two values returned for our MX query, one with a priority of 10 and another with a priority of 20. Lowest numbered MX records are the most preferred so when a mail server looks up the MX record for nullrouted.space it will use the one with the lowest priority value. If that mail server is unreachable, the mail server will then use the next lowest value.
The second component is the host aka the domain name of the mail server. Like I mentioned in the CNAME records section, this must be a name that points at A/AAAA records and not a CNAME record.
TXT records are type of record used to store arbitrary text for a DNS name. These days it is mostly used to store machine-readable data such as SPF (Sender Policy Framework), DKIM (DomainKeys Identified Mail) or domain ownership verification.
An example to demonstrate:
% dig +short nullrouted.space txt "v=spf1 include:spf.messagingengine.com include:webspf.asininetech.net -all" "google-site-verification=qb_NV84BGwtIW7E402JtHjux5gO_lVr1WI0XCPWcC0I"
In this example the name nullrouted.space has two TXT records, one is a SPF record and another is used by Google to verify domain ownership for use with Google’s webmaster tools.
That is all for this post of the Understanding DNS series. If you are interested in all the record types I did not mention, this Wikipedia page is a good place to get started.
In my next post I will be talking TTLs and caching. See y’all next time!