Security · 4 min read

SPF PermError: too many DNS lookups, and how to get under 10

By the Elematron team · Published

SPF (Sender Policy Framework) records authenticate mail senders by listing authorized IP addresses and mail servers. However, SPF has a hard limit: each DNS query during SPF validation counts toward a maximum of 10 lookups per check. Exceed that limit and receivers return a PermError (permanent error), causing legitimate mail to be rejected or deferred. This article explains the limit, identifies common causes, and shows you how to optimize your SPF record to stay under 10.

Understanding the SPF 10-Lookup Limit

RFC 7208 defines the SPF mechanism evaluation process. Each mechanism that requires a DNS query counts against the limit. A "lookup" occurs when the receiver's mail server performs a DNS query to evaluate an SPF mechanism—for example, looking up an A record, MX record, or following an include. When the receiver reaches 10 lookups, further mechanisms are not evaluated, and the result is PermError.

This limit exists to prevent denial-of-service attacks and reduce resolver load. It applies globally: all mechanisms in your SPF record, plus all nested includes, count toward the same pool. A single poorly designed SPF chain can waste lookups and cause legitimate mail to fail.

Common Causes of SPF Lookup Bloat

Strategies to Reduce DNS Lookups

Audit your current SPF record first. Use an SPF checker or analyzer to see which mechanisms are consuming lookups. Then apply these techniques:

Example: Before and After

A typical bloated SPF record might look like this:

v=spf1 include:_spf.google.com include:sendgrid.net include:servers.mcsv.net include:mail.zendesk.com a mx ptr ~all

This record uses at least 6 lookups: one for each include, plus one for A, one for MX, and one for ptr. If any included record itself contains includes, the total climbs higher and may exceed 10.

An optimized version consolidates and removes redundancy:

v=spf1 include:_spf.google.com ip4:192.0.2.0/24 ip4:198.51.100.0/24 a -all

This uses only 3 lookups: one for the Google include, one for the A record, and two IP ranges that require no lookup. The ptr mechanism is removed, and the MX mechanism is dropped because the A record covers the mail server. The result is faster, more reliable delivery and room for future additions.

Validation and Testing

After optimizing, validate your SPF record with a live DNS lookup tool or SPF checker. Confirm that your mail servers still pass SPF validation and that no legitimate senders are rejected. Monitor your mail logs for SPF PermError results over the next week to catch any issues.

SPF Record Generator
Build and optimize your SPF record while tracking DNS lookups in real time.
Open →
Every Elematron tool is free for everyone — no account needed.
Browse free tools →
Free tools for this
More from the blog
F5 XC Origin Pool Health Check Failures: Diagnosis and RecoveryRead →F5 BIG-IP GTM DNS Failover Design: Multi-Site Load BalancingRead →