Dev.to Security 🔐 Cybersecurity 👁 0 📖 1 min read

SPF "permerror: too many DNS lookups": what the 10-lookup limit is and how to fix it

Your SPF record looks fine, yet some receivers report spf=permerror, and your mail lands in spam or fails DMARC. A very common cause: the record needs more than 10 DNS lookups to evaluate. The rule RFC 7208 (

Your SPF record looks fine, yet some receivers report spf=permerror, and your mail lands in spam or fails DMARC. A very common cause: the record needs more than 10 DNS lookups to evaluate.

The rule

RFC 7208 (section 4.6.4) limits SPF evaluation to 10 mechanisms or modifiers that trigger a DNS query: include, a, mx, ptr, exists and redirect. Nested includes count too. Past 10, the result is permerror, and receivers treat SPF as failed.

ip4, ip6 and all do not count.

Why you hit it

Every SaaS tool asks you to add its include: your mail provider, your CRM, your newsletter tool, your helpdesk, your invoicing tool. Each include can itself contain several includes. Five services can easily add up to 12 or 15 lookups.

How to count

Expand each include recursively and count every include, a, mx, ptr, exists and redirect you meet. Or run a free check, with no signup, that does the count for you:
https://attackscout.com/en/tools/spf-check

How to fix it

  1. Remove what you no longer use. Old newsletter tools and trial services are the usual suspects.
  2. Replace a and mx with explicit ip4/ip6 when the addresses are stable.
  3. Send from a subdomain. Put marketing mail on news.example.com, with its own SPF record. Each domain gets its own 10-lookup budget.
  4. Be careful with "flattening" (replacing includes with the IPs they resolve to). It works, but provider IPs change, and a stale flattened record breaks silently. Only do it with automated updates.
  5. Never add a second SPF record. Two v=spf1 TXT records on one name is also a permerror.

Check the whole chain

SPF alone does not protect your domain. Receivers look at DMARC, which needs SPF or DKIM to pass and align with your From domain. After fixing SPF, check DKIM and DMARC too:

Questions about a tricky SPF record? Ask in the comments.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.