DNS record types

The DNS has five main types of records—A, AAAA, MX, TXT, CNAME, and * (ALL/ANY).

As we have learned, the DNS's primary purpose is to translate hostnames into IP addresses. This is done with two record types – type A and type AAAA. These records work in the same way, but A records return an IPv4 address, while AAAA records return an IPv6 address.

The MX record type is used to return mail server information. For example, if you wanted to send an email to larry@example.com, then the MX record(s) for example.com would indicate which mail server(s) receives emails for that domain.

TXT records can be used to store arbitrary information for a hostname. In practice, these are sometimes set to prove ownership of a domain name or to publish email sending guidelines. The Sender Policy Framework (SPF) standard uses TXT records to declare which systems are allowed to send mail for a given domain name. You can read more about SPF at http://www.openspf.org/.

CNAME records can be used to provide an alias for a given name. For example, many websites are accessible at both their root domain name, for example, example.com, and at the www subdomain. If example.com and www.example.com should point to the same address, then an A and an AAAA record can be added for example.com, while a CNAME record can be added for www.example.com pointing to example.com. Note that DNS clients don't query for CNAME records directly; instead, a client would ask for the A or AAAA record for www.example.com and the DNS server would reply with the CNAME record pointing to example.com. The DNS client would then continue the query using example.com.

When doing a DNS query, there is also a pseudo-record type called * or ALL or ANY. If this record is requested from a DNS server, then the DNS server returns all known record types for the current query. Note that a DNS server is allowed to respond with only the records in its cache, and this query is not guaranteed (or even likely) to actually get all of the records for the requested domain.

When sending a DNS query, each record type has an associated type ID. The IDs for the records discussed so far are as follows:

Record Type Type ID (decimal) Description
A 1 IPv4 address record
AAAA 28 IPv6 address record
MX 15 Mail exchange record
TXT 16 Text record
CNAME 5 Canonical name
* 255 All cached records

 

There are many other record types in use. Please see the Further reading section at the end of this chapter for more information.

It should be noted that one hostname may be associated with multiple records of the same type. For example, example.com could have several A records, each with a different IPv4 address. This is useful if multiple servers can provide the same service.

One other aspect of the DNS protocol worth mentioning is security. Let's look at that now.