Fix SPF PermError: Too Many DNS Lookups (Exceeding the RFC 7208 10-Lookup Limit)
Understand which SPF mechanisms count toward RFC 7208 §4.6.4's hard 10-lookup ceiling, why nested vendor includes blow the budget, and how to cut lookups safely.
Incident Symptom & RFC 7208 Root Cause
SMTP & Deliverability Symptom
Outbound customer emails fail authentication at Gmail, Microsoft 365, or Proofpoint with Authentication-Results: spf=permerror (too many DNS lookups), causing DMARC p=quarantine or p=reject bounces the moment marketing adds one more SaaS include: tag.
DNS Resolver & RFC 7208 Mechanics
RFC 7208 §4.6.4 mandates that an SPF verifier MUST abort evaluation and return PermError if evaluating a record requires more than 10 DNS-querying mechanisms/modifiers in total across the root record AND all nested child includes combined (counting include, a, mx, ptr, exists, and redirect=, whereas ip4, ip6, all, and exp cost 0 lookups).
Broken vs Verified DNS Configuration
; example.com TXT (14 DNS lookups total -> immediate RFC 7208 §4.6.4 PermError!)
; a (1) + mx (1) + google (4) + spf.protection.outlook (2) + sendgrid (1) + zendesk (1) + hubspot (2) + freshdesk (2) = 14!
example.com. 3600 IN TXT "v=spf1 a mx include:_spf.google.com include:spf.protection.outlook.com include:sendgrid.net include:mail.zendesk.com include:4412345.spf01.hubspotemail.net include:email.freshdesk.com ~all"; 1. Root organizational domain keeps ONLY human corporate mailbox & core CRM (6 lookups):
; Removed redundant 'a' & 'mx' (Google Workspace already covers outbound MX IPs!)
; Moved marketing/transactional ESPs onto dedicated Return-Path subdomains!
example.com. 3600 IN TXT "v=spf1 include:_spf.google.com include:mail.zendesk.com -all"
; 2. Transactional app mail isolated on bounce/Return-Path subdomain (1 lookup!):
bounces.example.com. 3600 IN TXT "v=spf1 include:spf.mtasv.net -all"
; 3. Marketing ESP isolated on dedicated subdomain (2 lookups!):
em.example.com. 3600 IN TXT "v=spf1 include:4412345.spf01.hubspotemail.net -all"Protocol Mechanics & Operational Deep Dive
The single biggest misconception about RFC 7208's 10-lookup limit is counting only top-level mechanisms on your root TXT record. The limit is recursive across the entire evaluation tree! For example, include:_spf.google.com currently triggers 4 DNS lookups (1 for _spf.google.com plus 3 nested _netblocks.google.com, _netblocks2, and _netblocks3 includes), even if the sending IP matches inside the first netblock or never uses Google at all if placed later in the chain.
Before reaching for brittle third-party 'dynamic SPF flattening' proxies (which introduce a new single point of DNS failure or stale IP blocks), apply three zero-cost structural cleanups that permanently solve 95% of lookup overflows: (1) delete cargo-cult 'a' and 'mx' mechanisms when your root web server does not send raw SMTP directly and your MX provider (Google Workspace or Microsoft 365) is already listed via include:; (2) purge legacy includes from churned SaaS tools whose contracts ended years ago; and (3) move bulk marketing, billing, and transactional ESPs onto dedicated envelope-sender (Return-Path) subdomains!
Why does subdomain delegation work seamlessly with DMARC while leaving From: you@example.com untouched? Because SPF evaluates the SMTP MAIL FROM (Return-Path) domain—NOT the visible RFC 5322 From: header! Under default relaxed DMARC alignment (aspf=r), an email with visible From: billing@example.com and envelope Return-Path: bounce@notify.example.com evaluates SPF exclusively against notify.example.com (giving that subdomain its own fresh 10-lookup budget!) while still passing DMARC SPF alignment for example.com!
RFC 7208 §4.6.4 DNS Lookup Cost per Mechanism
| Mechanism / Case | RFC 7208 Evaluation | Production Remediation |
|---|---|---|
| ip4:, ip6:, all, v=spf1 root TXT | 0 counted lookups toward the 10-mechanism limit (evaluated purely in memory after initial TXT fetch). | Use direct ip4:/ip6: CIDRs for static self-hosted MTA relays instead of 'a:mail.example.com'. |
| include:<domain> and redirect=<domain> | +1 lookup for the directive itself PLUS all counted mechanisms inside the target record recursively! | Audit nested depth in the OpsLint SPF Workbench; isolate third-party ESPs onto subdomains. |
| a, mx, exists:<domain>, ptr (deprecated) | +1 global mechanism lookup each; mx also enforces a separate <=10 A/AAAA lookup cap per MX! | Remove 'a' and 'mx' unless those exact hosts emit outbound SMTP outside your included ESPs. |
| Lookup #11 reached anywhere in evaluation | Verifier MUST return PermError; treated as authentication failure by DMARC! | Keep root SPF at <=8 lookups so an upstream SaaS vendor adding 1 child netblock cannot break your mail. |
Edge Cases & Engineering FAQs
If a message's IP matches the very first mechanism (ip4:...), do lookups #2 through #12 still cause a PermError?
Strict left-to-right evaluators stop as soon as a mechanism matches, meaning legitimate mail from mechanism #1 might pass while mail from mechanism #9 fails—AND an attacker spoofing your domain forces the receiver all the way to the end of the chain, hitting Lookup #11 -> PermError (where some receivers fail open or fail unpredictably instead of deterministic -all Reject)! Furthermore, pre-flight static validators reject >10 total lookups outright.
Does the initial DNS TXT query for example.com itself count as 1 of the 10 lookups?
No! Per RFC 7208 §4.6.4, the initial DNS lookup to retrieve the root domain's SPF TXT record is exempt; the counter starts at 0 when parsing the mechanisms inside that root record.
Why should we leave a 2-lookup safety margin (<=8 lookups) instead of stopping at 10/10?
You do not control how many child includes a third-party vendor puts inside their SPF record! If you sit at 10/10 today and an ESP splits _netblocks into one additional child include tomorrow morning, your entire domain drops into PermError without you touching DNS.
Aligned Transactional Delivery Infrastructure
Dedicated transactional delivery streams with custom Return-Path subdomain SPF alignment and 2048-bit DKIM signing.