TXT record lookup: the command for each tool
Windows always has nslookup; Linux and macOS add dig and host. Pick your tool and put in your domain. SPF is an ordinary TXT record on the domain itself, so the SPF lookup is the same query with a filter.
Only inserted into the commands in your browser.
All TXT records · dig · Linux, macOS
+short prints only the content, one TXT record per line in quotes. Drop +short to see the TTL and the response status as well.
dig +short TXT example.com"v=spf1 -all"All TXT records · nslookup · Windows, Linux, macOS
The command is the same on Windows, Linux and macOS; the output shown is from Linux and macOS, on Windows it wraps differently and the value sits on its own line below "text =". "Non-authoritative answer" only means the reply came from your resolver's cache, not straight from the domain's name server.
nslookup -type=TXT example.comServer: 192.0.2.53
Address: 192.0.2.53#53
Non-authoritative answer:
example.com text = "v=spf1 -all"All TXT records · PowerShell · Windows
Resolve-DnsName returns objects; the Strings property holds the record text. Without the second half you get a table with Name, Type, TTL and Strings.
Resolve-DnsName -Name example.com -Type TXT | Select-Object -ExpandProperty StringsAll TXT records · host · Linux, macOS
host ships with most Linux systems and macOS and answers with one sentence per record, handy for a quick look.
host -t TXT example.comexample.com descriptive text "v=spf1 -all"SPF · dig · Linux, macOS
SPF lives in a TXT record on the domain itself. The filter keeps only the line that starts with v=spf1. Two lines back means SPF is invalid.
dig +short TXT example.com | grep -i "v=spf1""v=spf1 -all"SPF · nslookup · Windows, Linux, macOS
nslookup cannot filter: look for the line with v=spf1. On Windows append "| findstr spf1", on Linux and macOS "| grep spf1".
nslookup -type=TXT example.comNon-authoritative answer:
example.com text = "v=spf1 -all"SPF · PowerShell · Windows
Where-Object keeps only records whose text starts with v=spf1. An empty result means there is no SPF record.
Resolve-DnsName -Name example.com -Type TXT | Where-Object { $_.Strings -match '^v=spf1' } | Select-Object -ExpandProperty StringsSPF · host · Linux, macOS
The same lookup with host, filtered down to the SPF record.
host -t TXT example.com | grep -i "v=spf1"example.com descriptive text "v=spf1 -all"If nothing comes back, there is no TXT record at that name. That is different from an error: without +short dig reports status NOERROR with zero answers, and nslookup prints "No answer".
Checking a record you just created
Your router and your ISP keep answers for as long as the TTL says, so right after saving you often still see the old state. Skip the caches and ask the responsible name server: find the domain's name servers first, then pass one of them after the @.
dig +short NS example.com
dig +short TXT example.com @ns1.example.net
# nslookup: name server as the last argument
nslookup -type=TXT example.com ns1.example.netIf the record is there, it is saved correctly and every other resolver will follow once its cached copy expires. If it is not, the problem sits in the DNS editor: wrong name, not saved, or the domain does not use that provider's name servers at all.
Reading the output
Four details cause most of the confusion:
- The quotes are presentation, not part of the value. Enter the text without them in your DNS editor or they end up in the record twice.
- A long record shows up as several chunks on one line ("v=DKIM1; p=MIIB…" "…QAB"). A single string holds at most 255 characters; receivers join the chunks without spaces.
- Several lines are several TXT records. That is normal (verification codes from Google, Microsoft and others); only v=spf1 must exist exactly once.
- The number before IN in the long dig output is the TTL in seconds. If it counts down between queries, the answer comes from a cache.
Common errors and what causes them
What you see, and why:
- Empty answer although the record is saved: the name in the editor is wrong. Many providers append the domain themselves, turning "_dmarc.example.com" into "_dmarc.example.com.example.com". Enter only the left part, usually "@" for the domain itself.
- NXDOMAIN from nslookup or dig: the queried name does not exist at all, often a typo or a subdomain without any record.
- Two lines with v=spf1: two SPF records make SPF invalid (PermError). Merge them into one.
- Old value after a change: caching. Ask the authoritative name server as shown above or wait for the TTL.
- nslookup on Windows resolves "example.com.corp.local": that is the network's DNS suffix being appended. A trailing dot ("example.com.") turns it off.
- The record exists at your host but nobody sees it: the domain uses other name servers, for example Cloudflare. What counts is what "dig +short NS" returns.
Checking without a terminal
The SPF checker queries the record authoritatively, follows every include and counts the DNS lookups, which is tedious by hand because each level needs another command. It shows whether the ten-lookup limit holds and how the record ends (-all, ~all, ?all). DMARC and DKIM use the same query under a different name; there is a separate guide for those.
What SPF does and does not protect against is covered in the glossary.