Skip to main content
Web Security·6 min read(1,155 words)·Published 2026-11-27

How to Get SPF Record for a Domain: Step-by-Step Lookup Guide

Learn how to get spf record for a domain using terminal commands and DNS lookups. Verify email authentication to prevent spoofing and protect delivery.

6 core sections·Technical reading pace: ~200 WPM

What You Need to Retrieve and Inspect an SPF Record

To get an SPF record for a domain, you query the public Domain Name System (DNS) for the domain's TXT records and locate the text entry that begins with v=spf1. Sender Policy Framework (SPF) records specify the authorized mail servers and IP addresses permitted to send email on behalf of a specific domain. By the end of this tutorial, you will have retrieved the active SPF record for any domain, evaluated its authorized sending mechanisms, and verified whether it properly authenticates outbound email.

Before you begin, ensure you have the domain name you want to query. If you are inspecting your own business domain, have access to your DNS hosting provider or domain registrar management portal to review unpublished draft changes. You will also need a command-line interface such as Terminal on macOS and Linux or Command Prompt and PowerShell on Windows. Alternatively, you can use browser-based tools or our Website Security Check to inspect public domain security records without using a terminal.

Querying the SPF Record Using Command-Line Tools

Tip

If a domain does not return a record starting with v=spf1, the domain has no SPF policy published, leaving its identity vulnerable to email spoofing.

The fastest way to look up an SPF record is through terminal-based DNS querying tools. On Linux and macOS systems, the dig utility queries DNS nameservers directly. By running dig example.com TXT +short, the system sends an inquiry to your configured resolver and returns all TXT records associated with that domain. You can scan the output for the entry starting with v=spf1.

On Windows systems, the nslookup tool provides the same functionality. Set the query type to TXT using the set type=txt parameter, followed by the domain name. The query returns the raw text records published on authoritative nameservers. If you suspect DNS propagation delays or caching issues, you can direct your query to a public resolver such as 8.8.8.8 or 1.1.1.1.

Command-line DNS TXT record lookups using dig and nslookup
# Linux and macOS query using dig
dig example.com TXT +short

# Query using a specific public resolver
dig @8.8.8.8 example.com TXT +short

# Windows Command Prompt or PowerShell query using nslookup
nslookup -type=TXT example.com

Checking SPF Records Through DNS Management Consoles

If you manage the domain yourself and need to find the record to edit it, log into the administrative dashboard of your domain registrar or DNS hosting provider. Navigate to the DNS management page, often labelled Zone Editor, DNS Records, or Advanced DNS.

Locate the table of active DNS records and look for entries where the record type is set to TXT. In the Host or Name column, your root domain is typically represented by an @ symbol or the domain name itself. In the Value, Data, or Content field, locate the entry starting with v=spf1. Modifying sending sources or integrating third-party email marketing software requires updating this specific line.

Never add a second SPF TXT record for the same hostname. Under standard email authentication specifications, defining multiple SPF records causes receiving mail servers to return a permanent error and fail validation. When managing complex mail environments with third-party senders, domain owners combine SPF with DMARC to receive aggregate feedback on delivery results, as detailed in the DMARC.org Overview.

How to Parse and Read SPF Record Components

Warning

The SPF specification enforces a strict limit of 10 DNS lookups per evaluation. Exceeding 10 lookups through nested include or mx mechanisms results in a validation PermError.

Once you retrieve the raw SPF record, you need to read its component mechanisms and qualifiers. An SPF record is processed from left to right. It begins with the mandatory version tag v=spf1, which identifies the TXT record as an SPF policy.

Between the version tag and the closing qualifier, you will find authorization mechanisms. The ip4 and ip6 mechanisms list explicit static IP addresses or CIDR ranges authorized to transmit email. The include mechanism instructs the receiving mail server to query another domain's SPF record, which is standard when using providers like Google Workspace or transactional relay platforms. The mx mechanism authorizes all servers listed in the domain's MX records.

The record concludes with an all mechanism preceded by a qualifier. The qualifier tells receivers how strictly to enforce the policy. A tilde (~all) represents a soft fail, suggesting that messages from unlisted servers should be accepted but flagged as suspicious. A hyphen (-all) indicates a hard fail, instructing receivers to reject unauthorized mail outright. Understanding these rules is a critical defense against impersonation, as discussed in our guide to Business Email Compromise: How It Works and How to Stop It.

Example of a standard SPF record breakdown
v=spf1 ip4:192.0.2.1 include:_spf.google.com ~all

# Breakdown:
# v=spf1                 -> SPF version 1
# ip4:192.0.2.1          -> Authorizes sending from IPv4 192.0.2.1
# include:_spf.google.com -> Includes Google Workspace sending servers
# ~all                   -> Soft fail for all other unlisted senders

Verifying SPF Authentication in Inbound Email Headers

Retrieving the published record verifies what is written in DNS, but testing an actual email delivery verifies that the receiving server parses the record as expected. Send a test email from your domain to an external mailbox on a service like Gmail.

Open the received message, access the original raw message or headers, and search for the Authentication-Results header. A properly configured SPF policy yields a line stating spf=pass, indicating that the client sending IP matches an authorized mechanism in the sender domain's SPF record. According to Google Workspace: Email sender guidelines, senders must set up SPF or DKIM email authentication, and senders transmitting 5,000 or more messages per day must configure both SPF and DKIM alongside DMARC.

If you want to inspect suspicious or unauthenticated inbound mail, you can paste the raw headers directly into our Phishing Email Header Analyzer to inspect SPF, DKIM, and DMARC alignment data without parsing raw headers manually.

How to Fix Common SPF Lookup and Configuration Errors

If your lookup command does not return an SPF record, check whether you queried the correct subdomain. SPF policies published at the root domain do not automatically protect subdomains unless explicitly defined. If you send mail from mail.example.com, query TXT records specifically for mail.example.com.

Another common failure occurs when administrators create multiple SPF records in DNS. When receiving servers encounter two distinct TXT entries beginning with v=spf1, they trigger a permanent error (PermError) and discard both. Merge all mechanisms into a single record string.

Finally, monitor your include mechanisms. If your organization uses multiple software-as-a-service providers, their nested includes can quickly push your record over the 10-lookup threshold. Remove unused services, replace generic domain includes with static IP ranges where feasible, or use subdomain segmentation to keep records within operational limits.

Step-by-Step Checklist

  1. 1
    Open your terminal or command prompt

    Launch Terminal on macOS or Linux, or open Command Prompt or PowerShell on Windows.

  2. 2
    Execute the DNS query command

    Run dig example.com TXT +short on macOS and Linux, or nslookup -type=TXT example.com on Windows, replacing example.com with your target domain name.

  3. 3
    Locate the SPF string in the output

    Review the returned TXT records to find the line that begins with the literal tag v=spf1.

  4. 4
    Verify against your DNS provider records

    Log into your domain registrar or DNS hosting console to ensure the retrieved string matches the active TXT record published in your zone editor.

  5. 5
    Validate mechanisms and lookup limits

    Count the number of include, a, mx, and redirect mechanisms in your record to ensure the total DNS lookup count does not exceed the limit of 10.

  6. 6
    Send a test email and check headers

    Deliver a test message to an external mailbox and view the raw Authentication-Results header to confirm that the receiving mail server returns spf=pass.

Frequently Asked Questions

Can a domain have more than one SPF record?+

No. A domain must never have more than one SPF record. If a receiving email server encounters multiple TXT records starting with v=spf1 for the same domain, it evaluates the result as a permanent error (PermError) and authentication fails. You must combine all authorized IPs and includes into a single record.

What is the difference between an SPF record and a TXT record?+

An SPF record is a specific type of TXT record. In earlier DNS standards, a dedicated SPF record type (type 99) existed, but it was deprecated. Today, all SPF records are published as standard DNS TXT records containing text that begins with the version prefix v=spf1.

Why does my dig command return no SPF record?+

If dig returns no output, either the domain owner has not published an SPF record, the domain is using a third-party DNS service that has not finished propagating, or you queried the root domain instead of the specific sending subdomain where the record was published.

What happens if my SPF record exceeds 10 DNS lookups?+

The SPF specification restricts policy evaluation to a maximum of 10 DNS lookups to prevent denial-of-service abuse. Each include, a, mx, ptr, and redirect mechanism counts toward this cap. If a receiver must perform more than 10 lookups, it stops processing and produces a PermError.

References & Further Reading

GuideWeb Security
How to Check Security Headers of a Website
Learn how to check security headers of a website using browser developer tools and terminal commands to defend against clickjacking, XSS, and MIME sniffing.
Read more
GuideWeb Security
How to Prevent a DDoS Attack (Step-by-Step Guide for 2026)
Protect your website infrastructure from crashing. Learn the 6 best defensive measures to block malicious traffic, implement rate limiting, and stop DDoS attacks before they cost you revenue.
Read more
GuideWeb Security
A Practical Guide to HTTP Security Headers for Web Developers
Why modern web applications need CSP, HSTS, and X-Content-Type-Options, and how to configure them properly in Next.js and Nginx.
Read more
GuideWeb Security
How to Protect Your Projects From Malicious npm Packages (and What GitHub's New Package Firewall Does)
GitHub launched a package firewall that blocks risky npm packages before they install. Learn how it works, who can use it and 10 steps any team can take today.
Read more
ReviewCybersecurity Hardware
Google Titan Security Key Review: Capable Phishing-Resistant MFA Hardware
An in-depth review of Google Titan Security Keys, examining passkey storage, hardware durability, FIDO2 authentication standards, pricing, and limitations.
Read more
News2026-11-28
Cybersecurity News Briefing: November 28, 2026
Today's briefing highlights a surge in active exploitation of critical flaws, including a zero‑day in Cacti, a site‑takeover bug in Drupal, and a long‑standing Linux NFS root‑escalation vulnerability. Government cloud services and procurement platforms in the US and Japan also faced breaches, while AI‑driven tools are increasingly used in attacks on critical infrastructure. Readers should prioritize applying all available patches for the disclosed vulnerabilities without delay.
Read more