DNS records explained: A, AAAA, CNAME, MX, TXT and more

By the PULSX team. Updated . 16 minute read.

TL;DR

A DNS record is one line that answers one question about a domain name, such as "which IP address?" (A and AAAA) or "which server takes the mail?" (MX). Each record has a name, a type, a value and a TTL, which is the number of seconds other servers may keep a copy. Most DNS problems are one wrong record or an old copy that has not run out yet.

Key takeaways

  • A and AAAA point a name at an IP address. CNAME points a name at another name.
  • A CNAME cannot sit at the bare domain or share a name with any other record.
  • MX says where mail goes. SPF, DKIM and DMARC are TXT records that say which mail is real.
  • NS records live in two places, your registrar and your DNS host, and they must match.
  • A change is seen by everyone only after the old TTL has run out. Lower the TTL a day before a planned move.
  • dig with +short, @server and +trace shows what is published and what is still cached.

What does DNS do in one request?

DNS turns a name such as www.example.com into the data a computer needs, most often an IP address. One request passes through up to four kinds of server, and each one either knows the answer or knows who to ask next.

  1. The resolver. Your device sends the question to a recursive resolver. This is run by your internet provider, your company, or a public service such as 1.1.1.1 or 8.8.8.8. If it has a recent copy of the answer, it replies at once.
  2. A root server. If not, the resolver asks one of the root servers. There are 13 root server names, a.root-servers.net to m.root-servers.net. The root does not know the answer. It replies: "ask the servers for .com".
  3. A TLD server. TLD means top-level domain, the last part of the name. The .com server replies with the nameservers for example.com.
  4. The authoritative server. This server holds the real records for example.com. It replies with the answer.

The resolver hands the answer to your device and keeps a copy. How long it keeps the copy is set by the record's TTL, covered later in this guide.

How a record is written

The records for one domain are called a zone. A zone file lists them one per line, in a format set by RFC 1035:

; name            TTL   class  type  value
www.example.com.  300   IN     A     192.0.2.34
FieldMeaning
NameThe hostname the record is about. The dot at the end means "this is the full name".
TTLSeconds a resolver may keep a copy. 300 is 5 minutes.
ClassAlways IN (internet) in practice.
TypeWhat kind of answer this is: A, MX, TXT and so on.
ValueThe answer itself.

Most DNS control panels hide the class and show @ for the bare domain, which is also called the apex. The examples below use the full zone file form.

What do A and AAAA records do?

An A record points a name at an IPv4 address, and an AAAA record points a name at an IPv6 address. They are the records a browser needs to reach your site.

A record

example.com.      300  IN  A  192.0.2.34
www.example.com.  300  IN  A  192.0.2.34

You can have more than one A record for the same name. Resolvers return all of them and clients pick one, which spreads visitors across servers.

Common mistake: adding the new IP address without removing the old one. Now there are two A records, and about half of your visitors are sent to the old server. Check what is really published with the A record lookup.

AAAA record

example.com.  300  IN  AAAA  2001:db8::34

Common mistake: publishing an AAAA record for a server that does not answer on IPv6, or leaving an old AAAA behind after a move. Visitors whose network prefers IPv6 get timeouts, while the site works for you on IPv4. Test it with curl -6 -I https://example.com and the AAAA record lookup.

What is a CNAME record, and why can it not go at the apex?

A CNAME record says "this name is another name for that name". The resolver then looks up the second name to find the address. It cannot go at the apex because a name with a CNAME may hold no other records, and the apex must hold SOA and NS records.

www.example.com.   3600  IN  CNAME  example.com.
shop.example.com.  3600  IN  CNAME  stores.example.net.

CNAMEs are useful when another company hosts something for you. They can change their IP addresses and your record stays correct.

The rule: a CNAME stands alone

RFC 1034 says that if a name has a CNAME, it must have no other data. So shop.example.com cannot have a CNAME and also an MX or TXT record.

Your bare domain, example.com, always has an SOA record and NS records. A CNAME there would break the rule. It would also hide your MX records, so mail would stop.

ALIAS, ANAME and CNAME flattening

Many DNS hosts offer a way round this. It is called ALIAS, ANAME or CNAME flattening, depending on the provider. You enter a hostname as the target, and the DNS host looks up that hostname itself and answers with plain A and AAAA records.

These are provider features, not standard record types. The name and behaviour differ between DNS hosts, and they do not carry over when you export a zone to another provider.

Common mistakes

  • Leaving off the final dot in a zone file. stores.example.net without the dot is read as stores.example.net.example.com.
  • Pointing an MX or NS record at a CNAME. RFC 2181 does not allow it, and some mail servers refuse to deliver.
  • A dangling CNAME. You delete the hosted service but leave the CNAME. Someone else can register that target and serve their content on your subdomain.

See where a name really ends up with the CNAME lookup.

What does an MX record do?

An MX record names the server that accepts email for a domain. Each MX record has a priority number, and sending servers try the lowest number first.

example.com.  3600  IN  MX  10 mx1.example.net.
example.com.  3600  IN  MX  20 mx2.example.net.

Here, mail goes to mx1. If mx1 does not answer, the sender tries mx2. Two records with the same number share the mail between them.

The value must be a hostname that has its own A or AAAA record. It cannot be an IP address and it should not be a CNAME.

Two special cases

  • No MX record at all: sending servers fall back to the domain's A record and try to deliver there.
  • A domain that should never get mail: publish a "null MX", defined in RFC 7505. Senders then fail at once with a clear error.
example.com.  3600  IN  MX  0 .

Common mistake: leaving the old provider's MX records in place after moving to a new mail provider. Some mail is then delivered to mailboxes nobody reads. Remove every old MX, then confirm with the MX lookup.

What is a TXT record for?

A TXT record holds free text attached to a name. Today it is mostly used to prove you own a domain and to publish email rules.

example.com.  3600  IN  TXT  "v=spf1 include:_spf.example.net -all"
example.com.  3600  IN  TXT  "site-verification=4f9a2c71b8"

A name can have many TXT records. The reader picks out the one it needs by how the text starts, for example v=spf1.

The 255 character limit

One quoted string in a TXT record can hold at most 255 characters. A longer value, such as a DKIM key, is written as several quoted strings in one record. The reader joins them with nothing in between:

s1._domainkey.example.com.  3600  IN  TXT  ( "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A..."
                                             "...rest of the key..." )

Most control panels do the splitting for you. Paste the value as one line and check what was saved.

Common mistakes

  • Two SPF records. A domain may have only one TXT record that starts with v=spf1. Two give an error and SPF fails for all mail.
  • The wrong name. Many panels add the domain for you. Typing _dmarc.example.com into the name box can create _dmarc.example.com.example.com.
  • Extra quote marks. If the panel adds quotes and you paste your own, the quotes become part of the value.

Read back exactly what is published with the TXT lookup.

What do NS and SOA records do?

NS records say which servers hold the records for a zone. The SOA record holds settings for the zone itself: who is in charge, a version number, and timers.

NS record

example.com.  86400  IN  NS  ns1.example-dns.net.
example.com.  86400  IN  NS  ns2.example-dns.net.

NS records exist in two places. One copy is held by the TLD servers, and you set it at your registrar (the company where you pay for the domain). The other copy is inside the zone at your DNS host. The two sets should be the same.

Common mistake: editing records at a DNS host that the domain no longer points to. If your changes seem to do nothing, run dig example.com NS +short or the NS lookup and check you are logged in to the provider it names.

A second mistake is switching nameservers before copying every record to the new host. Anything you did not copy stops resolving.

SOA record

SOA means "start of authority". Every zone has exactly one.

example.com.  3600  IN  SOA  ns1.example-dns.net. hostmaster.example.com. (
                    2026101201  ; serial
                    7200        ; refresh
                    3600        ; retry
                    1209600     ; expire
                    3600 )      ; minimum
FieldExampleMeaning
MNAMEns1.example-dns.net.The primary nameserver for the zone.
RNAMEhostmaster.example.com.The contact email, with the @ written as a dot. This one is [email protected].
Serial2026101201A version number. Secondary servers copy the zone when it goes up. A common format is the date plus a two digit counter.
Refresh7200How often secondary servers check for a new serial: every 2 hours.
Retry3600How long a secondary waits before it tries again after a failed check: 1 hour.
Expire1209600How long a secondary keeps answering if it cannot reach the primary: 14 days.
Minimum3600How long resolvers remember that a name does not exist (RFC 2308): 1 hour.

Common mistake: editing a zone file by hand and not raising the serial. The secondary servers see the same serial and keep the old data. Hosted DNS providers manage the serial for you. View yours with the SOA lookup.

What are CAA, SRV and PTR records?

These three are less common, and each has one clear job. CAA limits who may issue certificates, SRV says where a service runs, and PTR maps an IP address back to a name.

CAA record

A CAA record lists the certificate authorities that are allowed to issue certificates for your domain. It is defined in RFC 8659.

example.com.  3600  IN  CAA  0 issue "letsencrypt.org"
example.com.  3600  IN  CAA  0 issuewild ";"
example.com.  3600  IN  CAA  0 iodef "mailto:[email protected]"

Line 1 allows one authority. Line 2 says nobody may issue wildcard certificates. Line 3 asks for reports of refused requests. With no CAA record at all, any authority may issue.

Common mistake: adding a CAA record for one authority, then moving to a host or CDN that uses another. Certificate renewal then fails the next time it runs. See the SSL certificate expiry guide, and check the record with the CAA lookup.

SRV record

An SRV record gives the hostname and port for a named service. It is defined in RFC 2782. The name starts with the service and the protocol, each with an underscore.

_sip._tcp.example.com.  3600  IN  SRV  10 60 5060 sip1.example.com.

The four values are priority (10), weight (60), port (5060) and target. Lower priority is tried first. Weight shares the load between records with the same priority.

Common mistake: expecting an SRV record to send a website to another port. Browsers do not look up SRV records for web pages.

PTR record

A PTR record is the reverse of an A record. It lives under a special domain, with the IP address written backwards. For 192.0.2.34:

34.2.0.192.in-addr.arpa.  3600  IN  PTR  mail.example.com.

You do not set PTR records at your DNS host. The owner of the IP address controls them, which is usually your hosting provider.

Common mistake: running a mail server with no PTR record, or one that does not match. Many receiving servers reject or mark down mail when the PTR name does not point back to the same IP address. Check with dig -x 192.0.2.34 +short.

How do SPF, DKIM and DMARC work as TXT records?

All three are TXT records that help a receiving mail server decide whether a message that claims to be from your domain is real. SPF lists who may send, DKIM publishes a key to check a signature, and DMARC says what to do when both fail.

SPF

SPF lists the servers that may send mail for your domain. It is defined in RFC 7208 and sits at the domain itself.

example.com.  3600  IN  TXT  "v=spf1 ip4:192.0.2.10 include:_spf.example.net -all"
  • ip4:192.0.2.10 allows that address.
  • include:_spf.example.net also allows whatever your mail provider lists in its own SPF record.
  • -all means "reject everything else". ~all is the softer form: "treat everything else as suspect".

Common mistake: going over the limit of 10 DNS lookups. Each include, a, mx, exists and redirect counts, and so do the lookups inside each included record. Over 10, SPF returns an error. Count yours with the SPF checker.

DKIM

DKIM (RFC 6376) adds a signature to each message. The receiver fetches your public key from DNS to check it. The record name contains a "selector", which your mail provider gives you.

s1._domainkey.example.com.  3600  IN  TXT  "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A..."

The value after p= is the key, shortened here. A real 2048 bit key is longer than 255 characters, so it is split into several strings.

Common mistake: a key cut short when pasted. Every signature then fails.

DMARC

DMARC (RFC 7489) tells receivers what to do with mail that fails both SPF and DKIM for your domain, and where to send reports. It always lives at _dmarc.

_dmarc.example.com.  3600  IN  TXT  "v=DMARC1; p=none; rua=mailto:[email protected]"
TagMeaning
p=noneTake no action. Only send reports. Start here.
p=quarantinePut failing mail in the spam folder.
p=rejectRefuse failing mail.
rua=The address that gets the daily summary reports.
pct=25Apply the policy to 25% of failing mail. Useful while you tighten it.

Common mistake: going straight to p=reject. Any service that sends as your domain and is not yet in SPF or signed with DKIM has its mail refused. Start at p=none, read the reports, fix each sender, then move up. Check your record with the DMARC checker.

What is TTL, and how long does a DNS change really take?

TTL (time to live) is the number of seconds a resolver may keep a copy of a record. A change is seen by everyone once the old TTL has run out, counted from the moment you made the change.

People call this "propagation", but nothing is pushed out. Your new record is live on the authoritative servers within seconds or minutes. Each resolver simply keeps its old copy until that copy runs out, then asks again.

TTLIn plain timeGood for
3005 minutesRecords you are about to change, or may need to change fast
36001 hourA sensible default for most records
8640024 hoursRecords that almost never change, such as NS

Worked example: moving a site to a new server

Your A record has a TTL of 86400. You want to move on Friday at 10:00.

  1. Thursday before 10:00: lower the TTL to 300. Do not change the IP address yet. Resolvers that fetched the record just before this will keep the 86400 copy for up to 24 hours.
  2. Friday 10:00: change the IP address. Every resolver now holds a copy that lasts at most 300 seconds.
  3. Friday 10:05: resolvers that respect the TTL are all using the new address.
  4. Keep the old server running for a day or two. Some resolvers and apps hold records for longer than they should.
  5. Next week: raise the TTL back to 3600.

If you skip step 1, the same move takes up to 24 hours, and for that time visitors are split between the two servers.

Three cases that take longer

  • Nameserver changes. The NS records held by the TLD have their own TTL, which you cannot change. For .com it is 172800 seconds, which is 48 hours.
  • A name that did not exist. If someone looked up a name before you created it, the "not found" answer is cached for the SOA minimum, 3600 seconds in the example above.
  • Local caches. Browsers and operating systems keep their own short copies. Restarting the browser clears the first.

How do you look up DNS records with dig and nslookup?

Use dig name type on Linux and macOS, or nslookup -type=TYPE name on Windows. Both ask a resolver for one record type and print the answer.

dig

# Just the value
dig example.com A +short

# The full answer line, with the TTL
dig example.com MX +noall +answer

# Ask a chosen public resolver
dig @1.1.1.1 example.com TXT +short

# Ask the authoritative server directly, with no cache in the way
dig @ns1.example-dns.net example.com A +norecurse

# Follow the whole path: root, TLD, authoritative
dig +trace www.example.com

# Reverse lookup (PTR)
dig -x 192.0.2.34 +short

# DMARC and SOA
dig _dmarc.example.com TXT +short
dig example.com SOA +short

A full answer line looks like this:

example.com.    287    IN    A    192.0.2.34

The number 287 is the TTL counting down. The record was published with 300, and this resolver fetched it 13 seconds ago. Run the command again and the number will be lower. That tells you that you are reading a cached copy.

On Debian and Ubuntu, dig is in the dnsutils package. On Fedora and RHEL it is in bind-utils.

The status line

Without +short, dig prints a header with a status. It is the fastest clue you have.

StatusMeaning
NOERROR with an answerThe record exists.
NOERROR with no answerThe name exists, but has no record of that type.
NXDOMAINThe name does not exist at all.
SERVFAILThe resolver could not get a valid answer. The nameservers are unreachable, wrongly delegated, or DNSSEC checks failed.
REFUSEDThat server will not answer for this zone.

nslookup

nslookup -type=MX example.com
nslookup -type=TXT _dmarc.example.com 8.8.8.8
nslookup 192.0.2.34

The optional last value is the resolver to ask. The third command is a reverse lookup.

No terminal? The DNS lookup tool shows the records for a domain in the browser.

Which record is behind which symptom?

Start from what you can see, then check the one record most likely to cause it. Always compare the authoritative answer with what a public resolver returns, because the gap between them is a cache.

SymptomLikely recordHow to check
After a move, the site is new for some people and old for othersA: old copies still cached, or two A records publisheddig @1.1.1.1 example.com A and dig @8.8.8.8 example.com A. Compare the values and TTLs.
Works on one network, times out on anotherAAAA pointing at a server with no IPv6dig example.com AAAA +short then curl -6 -I https://example.com
www works, the bare domain does notNo A record (or ALIAS) at the apexdig example.com A +short
Incoming email does not arriveMX missing, wrong, or pointing at a name with no A recorddig example.com MX +short, then dig each target
Mail you send lands in spamSPF, DKIM, DMARC or PTRdig example.com TXT +short, dig _dmarc.example.com TXT +short, dig -x your sending IP
A certificate will not issue or renewCAA blocks the authority, or the _acme-challenge TXT record is missingdig example.com CAA +short
A new subdomain says "not found" after you added itThe "not found" answer is cached (SOA minimum)Ask the authoritative server with dig @ns1.example-dns.net. If it answers, wait out the SOA minimum.
Changes in your DNS panel do nothingNS points at a different providerdig example.com NS +short
The whole domain returns SERVFAILNS delegation is broken, or a DNSSEC record was left at the registrar after a movedig +trace example.com and see where it stops
A service cannot verify your domainTXT at the wrong name, or with extra quotesdig example.com TXT +short and compare character by character
A subdomain shows someone else's pageA CNAME left pointing at a service you closeddig shop.example.com CNAME +short

If the records look right and the site is still unreachable, the fault is past DNS. The website down checklist walks through the next steps in order.

Which DNS records should you monitor?

Monitor the records that would take your site or your mail offline if they changed: the A and AAAA records of your main hostnames, your MX records, your NS records and your SPF and DMARC TXT records. A wrong DNS record breaks things for everyone, and your servers show no error.

RecordWhy watch it
A and AAAAA wrong address sends visitors to the wrong server or to nothing. An uptime check on the server's IP address would not see it.
CNAMEA hosted service can change or remove the target you point at.
MXIf it changes or vanishes, incoming mail stops or goes elsewhere. It can go unnoticed, because missing mail makes no noise.
NSA change here moves control of the whole domain. It should never change without you knowing.
TXTAn SPF or DMARC record removed during a tidy-up sends your mail to spam.

Check from outside, on a schedule

DNS breaks at the moment someone edits a record, and that person is often not the one who would notice the damage. A check that runs every few minutes from outside your network turns that into an alert.

PULSX has a DNS monitor type for A, AAAA, CNAME, MX, TXT and NS records, next to its HTTP, TCP port, ping and heartbeat monitors. Checks run as often as every 60 seconds. It is free for 20 monitors and you can sign up without a card.

Three habits that prevent most DNS incidents

  • Export the zone before every change. A text copy lets you put every record back as it was.
  • Lower the TTL a day before a planned change and raise it afterwards.
  • Read the record back after you save it. Use dig against the authoritative server, not your memory of what you typed.

Common questions

What is the difference between an A record and a CNAME?+
An A record points a name straight at an IPv4 address. A CNAME points a name at another name, and the resolver then looks up that second name. Use an A record when you know the IP address. Use a CNAME when another company hosts the service and may change its addresses.
Can I put a CNAME on my root domain?+
No. A name with a CNAME may hold no other records, and the root (apex) of a domain must hold SOA and NS records. Many DNS hosts offer ALIAS, ANAME or CNAME flattening for this case. The DNS host looks up the target itself and answers with A and AAAA records.
How long do DNS changes take?+
As long as the old TTL of the record you changed. If the TTL was 3600, every resolver has the new value within 1 hour. If it was 86400, allow 24 hours. Nameserver changes take longer, because the TLD holds those records with its own TTL, which is 48 hours for .com.
What does the number in an MX record mean?+
It is the priority. Sending servers try the MX record with the lowest number first and move to the next one only if it does not answer. Records with the same number share the mail.
Are SPF, DKIM and DMARC separate record types?+
No. All three are published as TXT records. SPF sits at the domain itself and starts with v=spf1. DKIM sits at selector._domainkey.example.com and starts with v=DKIM1. DMARC sits at _dmarc.example.com and starts with v=DMARC1.
What TTL should I use?+
3600 seconds (1 hour) is a sensible default. Use 300 seconds for a record you are about to change, and lower it at least one old TTL before the change. Records that almost never change, such as NS, can use 86400 seconds.
What does NXDOMAIN mean?+
It means the name does not exist in DNS at all. It is different from an empty answer, where the name exists but has no record of the type you asked for. Resolvers cache an NXDOMAIN answer for the time set in the minimum field of the zone SOA record.
How do I check the DNS records for a domain?+
On Linux or macOS run dig example.com A +short, and swap A for MX, TXT, NS, CNAME, AAAA, SOA or CAA. On Windows run nslookup -type=MX example.com. Add @1.1.1.1 to dig to ask a chosen public resolver, or use dig +trace to follow the path from the root servers.

More guides

Free DNS, SSL and cron tools

Know the minute your site goes down.

PULSX checks your site, API, cron jobs and SSL certificate every 60 seconds. Free for 20 monitors, with no card.