DNS record types explained: A, AAAA, MX, TXT, CNAME and more

Updated

A DNS record is an entry in a domain’s zone that answers one question about a name. An A record answers “which IPv4 address?”, an MX record answers “which server receives this domain’s email?”, and so on. Every record has a name, a type, a TTL (how many seconds resolvers may cache it) and a value.

Common DNS record types
TypeWhat it holdsExample value
AIPv4 address192.0.2.10
AAAAIPv6 address2001:db8::10
CNAMEAlias to another nameshop.example.net.
MXMail server and its priority10 mail.example.com.
NSAuthoritative nameserverns1.example.net.
TXTText, including SPF, DMARC and verification codes"v=spf1 include:_spf.example.net -all"
SOAZone settingsns1.example.net. hostmaster.example.com. 2026093001 7200 3600 1209600 300
CAACertificate authorities allowed to issue0 issue "letsencrypt.org"
SRVHost and port for a service10 5 5060 sip.example.com.
PTRHostname for an IP addressmail.example.com.
NAPTRRewrite rules for services such as SIP100 10 "S" "SIP+D2U" "" _sip._udp.example.com.
DSHash of the domain’s key, stored in the parent zone12345 13 2 [digest]
DNSKEYPublic key that signs the zone257 3 13 [key data]

A and AAAA records

An A record maps a name to an IPv4 address, and an AAAA record maps it to an IPv6 address. A name can have several of each. Clients pick one of the addresses, which spreads the load across servers.

CNAME records

A CNAME makes one name an alias for another. The resolver follows it and returns the target’s records. A name with a CNAME cannot have any other records, so you cannot put a CNAME on the domain itself (example.com), only on names below it such as www.example.com. Some DNS providers offer an ALIAS or ANAME record that works around this.

MX records

MX records name the servers that accept email for a domain, each with a priority. Senders try the lowest number first. An MX record must point to a hostname that has A or AAAA records, not to an IP address or a CNAME. A domain that accepts no email can say so with a single null MX record pointing to “.” (RFC 7505). Look up any domain’s mail servers with the MX lookup.

TXT records

TXT records hold free text, and several standards use them. SPF records (v=spf1) list the servers allowed to send email. DMARC records live at _dmarc.example.com and DKIM public keys at selector._domainkey.example.com. Services such as Google Search Console ask you to add a TXT record to prove you own a domain. Each string in a TXT record is limited to 255 characters, so longer values are split into several strings that are joined back together. The SPF, DKIM and DMARC guide covers the email records in detail.

NS and SOA records

NS records list the authoritative nameservers for a zone. They appear twice: in the parent zone (for example .com), which delegates the domain, and in the domain’s own zone. The SOA (start of authority) record holds the zone’s settings: the primary nameserver, an administrator email written with a dot instead of @, a serial number that increases with each change, timers for zone transfers, and how long resolvers should cache “no such record” answers.

CAA records

A CAA record lists the certificate authorities allowed to issue TLS certificates for a domain. Certificate authorities must check it before they issue one (RFC 8659). If a domain has no CAA record, any certificate authority may issue for it.

SRV and NAPTR records

An SRV record gives the host and port for a named service, such as _sip._tcp.example.com, with a priority and a weight for load balancing. NAPTR records hold rewrite rules and are used mostly in telephony, for SIP and ENUM.

PTR records

PTR records power reverse DNS: they map an IP address back to a hostname. They live in special zones, in-addr.arpa for IPv4 and ip6.arpa for IPv6, controlled by whoever holds the address block, usually a hosting provider or ISP. Mail servers often check them. Try the reverse DNS lookup.

DS and DNSKEY records

These two records make DNSSEC work. DNSKEY records in the domain’s zone hold the public keys that sign its records. The DS record, published in the parent zone through your registrar, holds a hash of the domain’s key-signing key and links the parent to the domain. If the DS record and the keys stop matching, validating resolvers refuse to answer for the domain. Check a domain with the DNSSEC checker.

What is TTL?

TTL (time to live) is the number of seconds a resolver may keep a record in its cache. A TTL of 300 means five minutes and 86400 means one day. Short TTLs make changes visible sooner but send more queries to your nameservers. The DNS propagation guide explains how TTL affects changes.

How to read a record

In a zone file, a record is one line with five parts: www 3600 IN A 192.0.2.10. The parts are the name, the TTL in seconds, the class, the type and the value. The class is always IN, for internet. DNS control panels show the same parts as form fields and usually hide the class.

Two conventions cause confusion. The symbol @ stands for the domain itself. And in a zone file, a hostname that ends with a dot is complete, while one without a dot has the domain added to it. Writing mail.example.com without the final dot in the wrong place produces mail.example.com.example.com.

Records on the domain and on subdomains

Every name has its own set of records. The records for example.com say nothing about www.example.com, and each needs its own A, AAAA or CNAME record to resolve.

A wildcard record, written with an asterisk as the name, answers for any subdomain that has no records of its own. It is useful for services that create subdomains on demand. A wildcard never overrides a name that exists, so adding a record for shop.example.com takes that name out of the wildcard’s reach.

Which record do I need?

Common mistakes

Common questions

Can a name have both a CNAME and other records?

No. A CNAME must be the only record at its name. That rule is why a CNAME cannot sit on the domain itself, which already has NS and SOA records.

What is the difference between an A record and a CNAME?

An A record points a name directly at an IP address. A CNAME points a name at another name and lets that name’s records supply the address. Use a CNAME when a provider may change its addresses.

Do I need an AAAA record?

Only if your server has a working IPv6 address. An AAAA record that points to an address that does not respond makes the site slow or unreachable for visitors on IPv6.

Which record proves I own a domain?

Usually a TXT record containing a code from the service that asks for proof. Some services ask for a CNAME, and certificate authorities can also check a file on the website.

Where do I edit DNS records?

At the company that runs the domain’s nameservers. That may be the registrar, the web host or a separate DNS provider. A nameserver lookup shows which.

How many records can a domain have?

The DNS sets no practical limit. Providers may cap the number on cheaper plans.