DNS record types are the kinds of data a domain can store: A and AAAA hold IP addresses, CNAME makes an alias, MX routes email, TXT holds free-form text such as SPF policies, and NS names the servers that answer for the zone. To see any of them for a domain, run nslookup -type=MX example.com and swap in the type you want.
Each record has a name, a type, a time to live (TTL) and type-specific data. The types below come from the original DNS specification (RFC 1035) and later additions. For how a resolver finds the records in the first place, see How DNS works.
The DNS record types at a glance
| Type | Number | What it stores | Typical use |
|---|---|---|---|
| A | 1 | A 32-bit IPv4 address | Point a name at a server |
| AAAA | 28 | A 128-bit IPv6 address | Same, for IPv6 |
| CNAME | 5 | The canonical name an alias points to | Make www follow another name |
| MX | 15 | A mail host plus a preference number | Route incoming email |
| TXT | 16 | One or more text strings | SPF, domain verification |
| NS | 2 | A name server for the zone | Delegate a domain to a DNS host |
| SOA | 6 | Zone metadata: primary server, serial, timers | Start of every zone |
| PTR | 12 | A name, stored under a reverse-lookup name | Look up a name from an IP address |
| SRV | 33 | Priority, weight, port and target host | Locate a service on a domain |
| CAA | 257 | Which certificate authorities may issue certificates | Restrict TLS certificate issuance |
A and AAAA: name to IP address
An A record maps a name to a 32-bit IPv4 address. An AAAA record does the same for a 128-bit IPv6 address; RFC 3596 assigns it type 28. A name can have several of each, and resolvers may return them in any order, which is how simple load spreading works.
Example zone-file lines (documentation addresses, not real hosts):
example.com. 3600 IN A 192.0.2.10
example.com. 3600 IN AAAA 2001:db8::10
Browsers usually ask for both. If you publish only an A record, IPv6-only clients cannot reach the site directly. For the address formats themselves, see IPv4 vs IPv6.
CNAME: an alias for another name
A CNAME record says "this name is an alias of that name". The resolver restarts the lookup at the target and returns whatever it finds there.
www.example.com. 3600 IN CNAME example.com.
Two rules from RFC 2181 cause most CNAME mistakes:
- A CNAME cannot share a name with other records. The RFC says an alias name may have only DNSSEC-related records alongside it. You cannot add a CNAME and an MX or TXT record at the same name.
- NS and MX targets must not be aliases. The name used as the value of an NS record or MX record must not be an alias, so point those at names that have A or AAAA records.
The first rule is why you cannot put a CNAME on a root domain such as example.com: the root already has SOA and NS records. Some DNS providers offer a proprietary workaround under names such as ALIAS or CNAME flattening. Check your provider's documentation, because it is not part of the standard.
MX: where email goes
An MX record names a host that accepts mail for a domain and gives it a 16-bit preference. RFC 1035 says lower values are preferred.
example.com. 3600 IN MX 10 mail1.example.com.
example.com. 3600 IN MX 20 mail2.example.com.
Senders try mail1 first and fall back to mail2. The target must be a hostname with an address record, not an IP address and not a CNAME. When email to a domain fails, look up its MX records first and check that each target host resolves.
TXT: free-form text, mostly for email authentication and verification
A TXT record holds one or more text strings. RFC 1035 defines it as descriptive text, and in practice it carries machine-readable policies and proofs of ownership.
The best-known use is SPF. RFC 7208 says an SPF policy is published as a TXT record at the domain name, starting with v=spf1. Its own example:
example.com. TXT "v=spf1 +mx a:colo.example.com/28 -all"
That authorises the domain's MX hosts and the hosts at colo.example.com/28 to send mail, and fails everything else (-all). Three details from the RFC trip people up:
- A domain may have only one SPF record. Two
v=spf1TXT records at the same name is an error. - SPF must be published as TXT. The dedicated SPF record type (99) from the experimental phase is no longer used.
- An SPF evaluation may cause at most 10 DNS lookups (from
include,a,mx,ptr,existsandredirect). Beyond that the result is a permanent error.
Services that ask you to "verify your domain" usually give you a TXT value to add at the root or a subdomain. Unrelated TXT records can sit side by side.
NS and SOA: who runs the zone
An NS record names a server that is authoritative for a zone. Your registrar holds the NS records that delegate the domain to your DNS host, and the zone itself lists them too.
example.com. 86400 IN NS ns1.example.net.
example.com. 86400 IN NS ns2.example.net.
The SOA record marks the start of a zone and holds its administrative data. RFC 1035 defines these fields:
MNAME: the primary name server for the zone.RNAME: the mailbox of the person responsible.SERIAL: the zone's version number, increased on every change.REFRESH,RETRY,EXPIRE: timers that secondary servers use when copying the zone.MINIMUM: a floor value for the TTL of records exported from the zone.
You rarely edit an SOA record by hand on a hosted DNS service; the provider manages it.
PTR: from IP address back to name
A PTR record answers the reverse question: given an IP address, what is its name? RFC 1035 stores IPv4 reverse data under in-addr.arpa with the octets reversed, so 10.2.0.52 is looked up at 52.0.2.10.in-addr.arpa. IPv6 uses ip6.arpa with the address written as reversed hexadecimal digits (RFC 3596).
The reverse zone belongs to whoever owns the IP address block, usually your ISP or hosting provider, not to your domain's DNS host. Mail servers often check that a sending IP has a PTR record, so ask the provider that owns the address to set it.
SRV: finding a service and its port
An SRV record tells a client which host and port provide a named service. RFC 2782 gives the format:
_Service._Proto.Name TTL Class SRV Priority Weight Port Target
_sip._tcp.example.com. 3600 IN SRV 10 60 5060 sip1.example.com.
Clients must try the lowest-numbered priority they can reach first. Among targets with the same priority, weight shares the load: larger weights get a proportionally higher chance of being picked. Only software written to look up SRV records uses them, so a web browser does not.
CAA: who may issue certificates
A CAA record lets the domain holder name the certificate authorities (CAs) allowed to issue TLS certificates for it. RFC 8659 defines three tags:
issue: a CA that may issue certificates. A value of;forbids all issuance.issuewild: the same, but only for wildcard names, and it overridesissuefor them.iodef: where a CA can send reports of requests that violate the policy.
example.com. CAA 0 issue "ca1.example.net"
example.com. CAA 0 iodef "mailto:[email protected]"
If no CAA record applies, issuance is not restricted. A CA searches up the DNS tree from the requested name and uses the first CAA record set it finds.
How to look up any record type
Per Microsoft's nslookup documentation, the -type= option returns only the record type you name:
nslookup -type=AAAA example.com
nslookup -type=MX example.com
nslookup -type=TXT example.com 1.1.1.1
The optional last argument is the DNS server to ask; without it, nslookup uses your default server. Use nslookup 4.4.4.4 with an IP address for a reverse lookup. The tool prints one of these errors when a query fails:
Nonexistent domain: the name does not exist.No records: the name is valid, but it has no records of the type you asked for. This is the usual answer for a missing MX or AAAA record.timed outandNo response from server: the DNS server did not answer.
After you change a record, a cached answer can keep showing the old value until its TTL runs out. Querying a different server, as in the last example above, bypasses your local cache, and you can clear the local one with the steps in how to flush the DNS cache.
Which record do you need?
- Point
example.comat a server: A (and AAAA if the server has an IPv6 address). - Point
wwwat the same place: a CNAME toexample.com., or its own A record. - Receive email: MX records, then SPF in TXT.
- Prove you own the domain to a service: the TXT or CNAME value that service gives you.
- Move DNS hosting: change the NS records at your registrar.
- Limit who can issue certificates: CAA.
Frequently asked questions
- What is the difference between an A record and a CNAME record?
- An A record maps a name directly to an IPv4 address. A CNAME record maps a name to another name, and the resolver then looks up that second name to get the address. Use an A record when you know the address, and a CNAME when the name should follow whatever another name points to.
- Can I put a CNAME on my root domain?
- Not in standard DNS. RFC 2181 says a name with a CNAME record may have no other data (apart from DNSSEC records), and a root domain always carries SOA and NS records, so the two cannot coexist. Some DNS providers offer a non-standard 'ALIAS' or 'CNAME flattening' feature that returns A records instead; that is a provider feature, not a record type in the RFCs.
- Which DNS record types are needed to run a website and email?
- A website needs an A record, an AAAA record, or a CNAME that leads to one. Email needs MX records pointing at the mail hosts. Most domains also publish TXT records for SPF and other email authentication, and NS records at the registrar so the zone can be found.
- What does the number next to an MX record mean?
- It is the preference value. A lower number is tried first, so a record with preference 10 is used before one with preference 20. The higher-numbered host only receives mail when the lower-numbered one cannot be reached.
Sources
- RFC 1035: Domain Names, Implementation and Specification
- RFC 3596: DNS Extensions to Support IP Version 6 (AAAA)
- RFC 2181: Clarifications to the DNS Specification
- RFC 2782: A DNS RR for specifying the location of services (DNS SRV)
- RFC 8659: DNS Certification Authority Authorization (CAA) Resource Record
- RFC 7208: Sender Policy Framework (SPF)
- Microsoft Learn: nslookup