SPF Flattening: When It Helps and Hurts
Flattening buys lookup headroom by inlining IPs. It also freezes your record the day a vendor rotates their sending pool.

Why SPF Hits a Wall at Ten Lookups
Mailbox providers enforce a hard cap of ten DNS lookups per SPF check (RFC 7208). Each `include:`, `a`, `mx`, `ptr`, `exists:`, and `redirect=` counts, including lookups inside nested includes. Google Workspace plus Microsoft 365 plus two ESPs on one apex can cross ten while the TXT still looks tidy.
What flattening tries to do
Flattening means swapping `include:vendor.com` for the literal IPv4 and IPv6 ranges that vendor publishes today, sometimes kept current by a SaaS that rewrites your SPF TXT on a schedule. Lookup count drops because `ip4:` and `ip6:` mechanisms do not recurse the same way includes do.
Warning
“Flattening is a loan against future vendor IP changes. Someone has to pay it back.”
When Flattening Helps
Look, flattening is defensible when you truly need many authorized senders on one apex, you can't move senders to subdomains, and you've got automation that refreshes IP lists at least weekly from vendor documentation.
Good fit signals
- Validators report 9 to 10 lookups with one small include left to add
- Vendors publish stable SPF include targets with documented IP ranges
- You monitor DNS and have rollback if a flattening job writes bad TXT
Pro tip
When Flattening Hurts
Failure modes we see in audits
- Flattening service writes a TXT longer than some DNS UI limits, truncating mid-mechanism
- Stale `ip4:` entries after ESP migration while old includes were removed from the record text but IPs stayed
- Two SPF records after a flattening tool and a human both edit TXT
- Over-broad `/8` style ranges pasted to "make it work," which weakens authorization more than a tight include
Warning
Safer Paths Before You Flatten
Inventory senders. Remove dead includes left from churned vendors.
Run lookup count at zerohook.org/spf-checker. Know your number before you add anything.
Move bulk mail to a dedicated subdomain with its own SPF and DKIM keys.
Use `redirect=` on a subdomain to centralize policy if your DNS provider supports it cleanly.
If you must flatten, document which service owns TXT writes and alert when it changes records.
Re-count lookups after every flattening job; permerror is silent until Gmail rejects mail.
Frequently Asked Questions
Key takeaways
Ten lookups is a hard receiver limit; permerror breaks auth even when dig looks fine.
Flattening trades lookup headroom for operational risk when IPs rotate.
Subdomains and redirects often beat flattening on apex domains with many ESPs.
Never run two SPF TXT records after a tool edits DNS.
Count lookups after every DNS change, not only at initial setup.
Share this analysis
Help others discover this content
More from our blog

How to Check an SPF Record (3 Ways)
Three ways to check an SPF record: dig and nslookup, PowerShell for Microsoft 365 admins, and a validator that counts DNS lookups. Plus how to read what you find.

Google Workspace SPF Record Mistakes
Google Workspace SPF setup: the correct include:_spf.google.com line, Mailchimp and HubSpot add-ons, and the migration mistakes that leave DMARC failing while Admin looks green.

SPF Record Syntax: Complete Reference
SPF record syntax from v=spf1 through -all: includes, lookup limits, permerror traps, and provider templates. The reference we use before editing any production TXT record.