How to check DNS TXT records with nslookup and dig

TL;DR

When your email lands in spam, or a service cannot confirm you own your domain, the answer is usually in the domain's DNS TXT records. You can read them in one command, with a tool your computer already has: nslookup on Windows and macOS, dig on macOS and Linux, or Resolve-DnsName in PowerShell. The records that matter for email are SPF (who may send for you), DKIM (a signature on each message), and DMARC (what to do when those fail), and this post shows how to read each one.

When email from a domain lands in spam, or a service says it cannot verify that you own a domain, the answer is usually sitting in the domain’s DNS TXT records. You do not need a lookup website to check them. Every computer already has a tool that will show you, in one command: nslookup on Windows, macOS, and Linux, dig on macOS and Linux, and Resolve-DnsName in PowerShell.

This guide gives you the commands to copy, shows what the output looks like, and then explains what the SPF, DKIM, DMARC, and verification records in that output mean, including the mistakes that most often break them.

Quick reference: commands to check TXT records

Replace example.com with the domain you are checking.

TasknslookupdigPowerShell
All TXT recordsnslookup -type=TXT example.comdig TXT example.com +shortResolve-DnsName example.com -Type TXT
DMARC recordnslookup -type=TXT _dmarc.example.comdig TXT _dmarc.example.com +shortResolve-DnsName _dmarc.example.com -Type TXT
DKIM keynslookup -type=TXT selector._domainkey.example.comdig TXT selector._domainkey.example.com +shortResolve-DnsName selector._domainkey.example.com -Type TXT
Name serversnslookup -type=NS example.comdig NS example.com +shortResolve-DnsName example.com -Type NS
Ask one servernslookup -type=TXT example.com 8.8.8.8dig @8.8.8.8 TXT example.com +shortResolve-DnsName example.com -Type TXT -Server 8.8.8.8

What is a DNS TXT record

A TXT record is a DNS record that holds plain text. DNS was built to map names to addresses, and TXT is the record type that lets a domain publish anything else: most often, instructions for mail servers and proof of ownership for services like Google and Microsoft.

A domain can have several TXT records at once, and some live on special names under the domain rather than on the domain itself. The common ones:

RecordWhere it livesStarts withWhat it does
SPFthe domain itselfv=spf1Lists the servers allowed to send email for the domain
DKIMselector._domainkey.domainv=DKIM1Publishes the public key that checks a message’s signature
DMARC_dmarc.domainv=DMARC1Says what to do with mail that fails, and where to send reports
Verificationusually the domain itselfvariesProves to a service that you control the domain

Check TXT records with nslookup

nslookup ships with Windows, macOS, and Linux, so it is the one command that works everywhere. Ask it for the TXT type:

nslookup -type=TXT example.com

The answer lists each TXT record on its own line:

Non-authoritative answer:
example.com	text =

	"_k2n1y4vw3qtb4skdx9e7dxt97qrmmq9"
example.com	text =

	"v=spf1 -all"

“Non-authoritative” means the answer came from your resolver’s cache, not from the domain’s own name server. That is normal. When you need the newest value, ask the authoritative name server, as shown further down.

To send the question to a specific DNS server, add it after the domain. This asks Google Public DNS:

nslookup -type=TXT example.com 8.8.8.8

Check TXT records with dig

On macOS and Linux, dig gives cleaner output and more control. On Linux it comes in the dnsutils package (Debian and Ubuntu) or bind-utils (Fedora, RHEL, and similar). +short prints only the records:

dig TXT example.com +short
"v=spf1 -all"
"_k2n1y4vw3qtb4skdx9e7dxt97qrmmq9"

To ask a specific resolver instead of your default one, put it after an @:

dig @8.8.8.8 TXT example.com +short

Leave off +short when something looks wrong. The full output shows the status: line (NOERROR or NXDOMAIN), the TTL of each record, and which server answered, which is exactly what you need for troubleshooting.

Check TXT records in PowerShell

On Windows, PowerShell’s Resolve-DnsName returns the records as a table, including the TTL (how many seconds resolvers may cache the answer):

Resolve-DnsName -Name example.com -Type TXT
Name        Type TTL Section Strings
----        ---- --- ------- -------
example.com TXT  300 Answer  {v=spf1 -all}
example.com TXT  300 Answer  {_k2n1y4vw3qtb4skdx9e7dxt97qrmmq9}

Because the result is an object rather than text, you can filter it. This prints only the SPF record:

Resolve-DnsName example.com -Type TXT | Where-Object { $_.Strings -like 'v=spf1*' } | Select-Object -ExpandProperty Strings

Add -Server to ask a specific DNS server, and -DnsOnly to skip local sources such as the hosts file.

To publish or repair these records after checking them, follow the SPF, DKIM and DMARC setup guide.

How to read an SPF record

An SPF record starts with v=spf1. The rest is a list of mechanisms that describe who may send mail for the domain, read left to right, and it ends with what to do about everyone else. Here is a typical record for a domain that sends from Google Workspace, a newsletter service, and its own server:

v=spf1 ip4:203.0.113.25 include:_spf.google.com include:mail.example.net ~all
PartMeaning
v=spf1This is an SPF record. It must come first.
ip4:203.0.113.25This one IPv4 address may send. ip6: does the same for IPv6, and both accept ranges such as 203.0.113.0/24.
include:_spf.google.comAlso allow every server listed in Google’s SPF record.
include:mail.example.netAlso allow the servers a second provider publishes.
a or mxAllow the servers the domain’s own A or MX records point to.
~allEverything else: soft fail.

The prefix on all (its qualifier) is the policy for every server not listed:

  • -all is a fail: those servers are not allowed to send for the domain.
  • ~all is a soft fail: those servers are probably not allowed.
  • ?all is neutral: the domain makes no statement.
  • +all is a pass for anyone, which means the record protects nothing. Never publish it.

The record on example.com itself, v=spf1 -all, lists no servers and ends in -all. It says no server may send mail for that domain at all, which is the right SPF record for any domain that never sends email.

Two rules from the SPF standard, RFC 7208, cause most real problems:

  1. Exactly one SPF record. If a domain has two TXT records that both start with v=spf1, the SPF check returns a permanent error (permerror). This usually happens when someone adds a new email tool and pastes its suggested record instead of merging it into the one that was already there.
  2. At most 10 DNS lookups. The include, a, mx, ptr, and exists mechanisms and the redirect modifier each cost a DNS lookup, and the lookups inside every included record count too. More than 10 in total is also a permerror. ip4 and ip6 cost nothing, so they are the way to add a server without adding a lookup. The standard also says not to publish ptr at all.

How to check a DMARC record

DMARC lives on its own name, _dmarc in front of the domain:

nslookup -type=TXT _dmarc.example.com
"v=DMARC1;p=reject;sp=reject;adkim=s;aspf=s"

The record is a list of tags separated by semicolons. The ones you will see most:

TagMeaning
v=DMARC1Required, and must come first, or the record is ignored.
p=Policy for mail that fails: none (only report), quarantine (treat as suspicious, usually spam), or reject.
sp=The same policy for subdomains. Without it, p= applies to them too.
rua=Where to send aggregate reports, as mailto: addresses.
ruf=Where to send failure reports for individual messages.
adkim= and aspf=Alignment: r (relaxed, the default) lets a subdomain match; s (strict) needs the exact domain.

DMARC passes when a message passes SPF or DKIM and the domain that passed matches the domain in the visible From address. That alignment requirement is why a message can pass SPF and still fail DMARC.

The DMARC standard was revised in May 2026 as RFC 9989, which replaces RFC 7489. The record format above still works. The revision drops the pct tag, adds t= (a test mode flag) and np= (a policy for subdomains that do not exist), and treats a record with no p= as p=none. If your record still carries pct=, it does no harm, but newer receivers ignore it.

How to check a DKIM record

DKIM keys live on their own name too: a selector, then _domainkey, then the domain. The email provider picks the selector, so you need it before you can look the key up. To find it, open any message the domain sent, view the original message or full headers, and find the DKIM-Signature header:

DKIM-Signature: v=1; a=rsa-sha256; d=example.com; s=s1; ...

s= is the selector and d= is the signing domain. Put them together:

nslookup -type=TXT s1._domainkey.example.com
dig TXT s1._domainkey.example.com +short

A DKIM record carries a few tags of its own:

  • v=DKIM1 is the version. If present, it must come first.
  • k=rsa is the key type. RSA is the default.
  • p= is the public key, a long base64 value. An empty p= means the key has been revoked, and signatures that use it fail.
  • t=y means the domain is testing DKIM.

Each quoted string in a TXT record can hold at most 255 characters, so a 2048 bit key comes back split into several quoted pieces. Mail servers join them back together without spaces. That split is not an error.

Some providers publish DKIM as a CNAME instead of a TXT record. Microsoft 365, for example, has you add selector1._domainkey and selector2._domainkey as CNAMEs that point at keys Microsoft hosts. Your TXT lookup still works: the resolver follows the CNAME, and the output shows the canonical name before the key.

Domain verification TXT records

Many services ask you to prove you control a domain by adding a TXT record with a value they generate. Two common examples:

  • Google (Search Console and Google Workspace) uses a value that starts with google-site-verification=, added at the root of the domain (@ or a blank host field in most DNS dashboards).
  • Microsoft 365 uses a value that starts with MS=ms followed by digits.

These records do nothing for email. They only answer the service’s question, “does whoever set this up control the DNS?” Leave them in place after you verify. Google’s own help says the domain stays verified only while the record exists, and other services check again from time to time.

A domain collects these over the years. A token for a service you no longer use is harmless, but it is fine to remove once you are sure nothing depends on it.

Check the authoritative name server

When you have just added or changed a record, your resolver may still be serving the old answer until its TTL runs out. Ask the domain’s own name server instead. First find it:

nslookup -type=NS example.com
example.com	nameserver = hera.ns.cloudflare.com
example.com	nameserver = elliott.ns.cloudflare.com

Then send the TXT question straight to one of the name servers it lists:

nslookup -type=TXT example.com hera.ns.cloudflare.com
dig @hera.ns.cloudflare.com TXT example.com +short
Resolve-DnsName example.com -Type TXT -Server hera.ns.cloudflare.com

If the authoritative server shows the new record, the change is live, and other resolvers will catch up as their cached copies expire. If it does not, the change has not been published, or it was made somewhere that is not actually serving the domain.

The NS lookup also answers a question that trips up a lot of people: where is this domain’s DNS hosted? The name servers tell you. If they belong to Cloudflare, records added at your registrar are never seen, however long you wait.

Common TXT record errors and what they mean

NXDOMAIN, or “Non-existent domain”. The name itself does not exist. For a DMARC or DKIM lookup, it usually means the record was never created, or the selector is wrong. In dig, the full output shows status: NXDOMAIN.

No answer, but no error. The name exists but has no TXT record. dig shows status: NOERROR with an empty answer section. On Windows, nslookup often prints the zone’s SOA record (the “primary name server” and “default TTL” lines) instead of a TXT answer; that is how it says “nothing here”.

The record is on the wrong name. Many DNS dashboards add the domain to whatever you type in the host field, so typing _dmarc.example.com creates _dmarc.example.com.example.com. Enter only _dmarc, and use @ for the domain itself. Look up the doubled name to confirm that is what happened.

Two SPF records. Merge them into one v=spf1 record with every provider’s mechanisms, and a single all at the end. Microsoft’s setup guide says the same: add its include to the existing record rather than creating a second one.

Too many DNS lookups in SPF. Count the lookups, including the ones inside each include. Remove providers you no longer use, and replace includes for your own servers with ip4: or ip6: ranges.

Quotes or spaces inside the value. Some dashboards add the surrounding quotes for you, and some do not. A value saved with literal quote marks, or with a line break pasted into the middle of a DKIM key, will not parse. The output of the lookup shows exactly what was saved.

The change does not show yet. Compare the authoritative answer with your resolver’s. If they differ, wait out the TTL. If you plan a change, lower the record’s TTL a day ahead so the switch happens faster.

A TXT record troubleshooting checklist

When email from a domain is failing or a verification will not go through, work through this in order:

  1. Run nslookup -type=NS on the domain and confirm you are editing DNS at the provider those name servers belong to.
  2. List the TXT records on the domain. Confirm there is exactly one v=spf1 record and that it ends in -all or ~all.
  3. Check that every service that sends mail for the domain appears in the SPF record, and count the lookups.
  4. Look up _dmarc on the domain. Confirm the record starts with v=DMARC1 and has the policy you expect.
  5. Find the DKIM selector in a recent message’s headers and look up selector._domainkey on the domain. Confirm p= is not empty.
  6. For a verification, confirm the token is at the name the service asked for, usually the domain itself.
  7. Ask the authoritative name server directly to rule out caching.

Sources

Frequently asked questions

What is a DNS TXT record used for?

A TXT record publishes text for other systems to read. Most domains use TXT records for email authentication (SPF, DKIM, and DMARC) and for verification tokens that prove ownership of the domain to services like Google Search Console and Microsoft 365.

How do I check a DNS TXT record from the command line?

Run nslookup -type=TXT followed by the domain on Windows, macOS, or Linux. On macOS and Linux, dig TXT followed by the domain and +short prints only the records. In PowerShell, use Resolve-DnsName -Name followed by the domain and -Type TXT.

How do I check a domain's SPF record?

Look up the domain's TXT records with nslookup -type=TXT, dig TXT, or Resolve-DnsName and find the one that starts with v=spf1. There should be exactly one. Two records that start with v=spf1 make SPF return a permanent error.

Can a domain have more than one TXT record?

Yes. A domain can have many TXT records, one for each purpose. The exception is SPF: a domain should have exactly one record that starts with v=spf1, because two SPF records make SPF checks fail.

How long does a TXT record change take to show up?

The domain's authoritative name server shows a change as soon as the DNS host publishes it. Other resolvers can keep serving the old value until its TTL, the cache time in seconds, runs out. Query the authoritative name server directly to confirm the change is live.

What is the difference between nslookup and dig?

Both ask DNS servers for records. nslookup comes with Windows, macOS, and Linux. dig comes with macOS and is a standard package on Linux (dnsutils or bind-utils); it shows more detail by default, and its +short option prints only the answer.

Why is my DKIM TXT record split into several strings?

Each quoted string in a TXT record can hold at most 255 characters, so long values such as DKIM public keys are stored as several strings. Mail servers join them back together without spaces, so the split is not an error.