Home › Guides › Networking › DNS record types explained (A, AAAA, CNAME, MX, TXT, NS)

DNS record types explained (A, AAAA, CNAME, MX, TXT, NS)

What each common DNS record does, how to write them, and the rules about CNAMEs, MX, TXT and TTLs that cause most DNS mistakes.

By the tools4free.dev team · Last reviewed 4 December 2026

A DNS record is one entry in a domain's zone that tells resolvers something about a name. The ones you meet most are A (name to IPv4 address), AAAA (name to IPv6 address), CNAME (one name is an alias for another), MX (where email goes), TXT (free-form text, used for email security and ownership checks) and NS (which servers are authoritative). This guide explains each, shows realistic zone entries, and covers the rules that cause most outages.

How a lookup uses records

When you type a domain into a browser, a resolver (usually run by your ISP or a public DNS provider) asks the DNS hierarchy for the record type it needs. For a web page, that is normally A or AAAA. It starts at the root servers, follows the NS delegations down to the domain's authoritative servers, and receives an answer along with a TTL, the number of seconds the answer may be cached. DNS messages and the core record types are defined in RFC 1035. Every record has the same shape: a name, a TTL, a class (almost always IN for Internet), a type and the data.

www.example.com.   3600   IN   A      192.0.2.10

The trailing dot means the name is absolute. The addresses in this guide come from ranges reserved for documentation (192.0.2.0/24 and 2001:db8::/32), so they are safe to copy as examples.

The records, one by one

TypeMapsExample dataTypical use
AName to IPv4 address192.0.2.10Web servers, any IPv4 service
AAAAName to IPv6 address2001:db8::10The IPv6 version of A
CNAMEName to another nameshop.example.net.Pointing a subdomain at a hosted service
MXDomain to mail servers10 mail.example.com.Receiving email
TXTName to text"v=spf1 -all"SPF, DKIM, DMARC, ownership proof
NSZone to name serversns1.example.org.Delegating a domain or subdomain
SOAZone metadataserial, refresh, retry, expirePresent once per zone
PTRAddress to namehost.example.com.Reverse lookups
CAAWhich CAs may issue certificates0 issue "ca.example"Limiting certificate issuance

A and AAAA

These are the records that make a site reachable. AAAA, defined in RFC 3596, uses the same idea as A with a 128-bit address. A name may have several A or AAAA records, and resolvers will return them all, which is a simple way to spread traffic. If a name has both, a modern device will try the IPv6 address first and fall back quickly if it fails.

CNAME

A CNAME says "this name is really that other name". The resolver restarts the lookup at the target. It is useful when a provider tells you to point shop.example.com at its own hostname, because the provider can change the underlying IP addresses without you editing anything.

The rule that surprises people: a name with a CNAME cannot have any other record type. That includes the zone apex (example.com itself), which must carry SOA and NS records. So you cannot put a standard CNAME at the bare domain. Some DNS providers offer a vendor-specific "ALIAS" or "flattened CNAME" feature to work around it, but that is not a DNS record type you can rely on across providers.

MX

An MX record has a preference number and a host name. Senders try the lowest number first:

example.com.  3600  IN  MX  10  mail1.example.com.
example.com.  3600  IN  MX  20  mail2.example.com.

Here mail1 is tried first, and mail2 only if it is unreachable. The target of an MX must be a name with address records, not a CNAME and never a raw IP address.

TXT

A TXT record holds text, and in practice most email authentication lives here. Three common cases:

Services also ask you to add a TXT record to prove you control a domain. A single text string inside a record is limited to 255 characters; longer values, such as DKIM keys, are split into several quoted strings in one record, which resolvers join.

NS and SOA

NS records list the authoritative servers for a zone. The same set also appears at the parent (your registrar's registry entry for the domain), and the two should match. SOA holds the zone's primary server, an administrator contact, a serial number and timers for secondary servers. You rarely edit SOA by hand, since your DNS host manages it.

Worked example 1: launching a site with email

You register example.com, host the site on a server at 192.0.2.10 (IPv6 2001:db8::10) and use a hosted mail service. A reasonable first zone:

example.com.        3600  IN  A      192.0.2.10
example.com.        3600  IN  AAAA   2001:db8::10
www.example.com.    3600  IN  CNAME  example.com.
example.com.        3600  IN  MX     10 mx.mailhost.example.net.
example.com.        3600  IN  TXT    "v=spf1 include:_spf.mailhost.example.net -all"
_dmarc.example.com. 3600  IN  TXT    "v=DMARC1; p=none; rua=mailto:dmarc@example.com"

The bare domain uses A and AAAA directly, because it cannot be a CNAME. The www name is a CNAME to the apex, so if the IP changes you edit one place. The DMARC policy starts at p=none to collect reports before you enforce anything.

Worked example 2: moving a site safely with TTLs

You plan to change the web server's IP. The current TTL is 86400 seconds (24 hours), so resolvers that already have the answer may keep it for up to a day. Do this:

  1. A day or more before the move, lower the TTL on the A record to 300 (5 minutes).
  2. Wait for the old TTL to expire, so every cache now holds the short one.
  3. Change the address. Within about five minutes, resolvers pick up the new one.
  4. After the move is confirmed, raise the TTL again to reduce load and lookup delay.

The common error is lowering the TTL and changing the address in the same minute. Caches still hold the old 24-hour value and keep serving the old address.

Common mistakes

Checking your records

Ask for one record type at a time, and ask the authoritative server to avoid stale caches. The command-line tools dig and nslookup do this, for example dig example.com MX. If your result differs from what you set, check three things: that you edited the zone at the provider your NS records actually point to, that the TTL has expired, and that the name you typed matches exactly.

Try it: look up the A, AAAA, MX, TXT and NS records of any domain with the DNS lookup tool. It is a good way to see how a real site's records compare with the examples above.

Frequently asked questions

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

An A record gives an IPv4 address. A CNAME gives another name, which must then be resolved. Use A when you know the address, and CNAME when a provider wants you to follow its hostname.

How long does DNS take to update?

Authoritative servers answer with the new data straight away. What takes time is the expiry of cached copies, which is bounded by the old TTL. Hours are common if the TTL was long.

Can a domain have more than one MX record?

Yes, and it should if you want a backup. The preference numbers set the order, and equal numbers share load.

Is DNS private?

Traditional DNS queries are sent unencrypted. DNS over HTTPS, described in RFC 8484, wraps them in HTTPS so that a network observer cannot read them, although the resolver you choose can still see them.

Sources