<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: CaptainDNS</title>
    <description>The latest articles on DEV Community by CaptainDNS (@captaindns).</description>
    <link>https://dev.to/captaindns</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4235444%2Fa56adb72-60fb-4d3e-a93a-ee3ea83cb4cc.png</url>
      <title>DEV Community: CaptainDNS</title>
      <link>https://dev.to/captaindns</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/captaindns"/>
    <language>en</language>
    <item>
      <title>SPF "too many DNS lookups": how to fix the 10-lookup limit</title>
      <dc:creator>CaptainDNS</dc:creator>
      <pubDate>Mon, 09 Nov 2026 15:47:46 +0000</pubDate>
      <link>https://dev.to/captaindns/spf-too-many-dns-lookups-how-to-fix-the-10-lookup-limit-4dh3</link>
      <guid>https://dev.to/captaindns/spf-too-many-dns-lookups-how-to-fix-the-10-lookup-limit-4dh3</guid>
      <description>&lt;p&gt;Your SPF record looks fine and your mail provider says everything is configured, yet DMARC fails and messages land in spam. One quiet cause: the SPF record went over the 10-lookup limit.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rule
&lt;/h2&gt;

&lt;p&gt;RFC 7208 (section 4.6.4) caps SPF evaluation at &lt;strong&gt;10 DNS queries&lt;/strong&gt;, nested ones included. Go over and the receiver returns a &lt;code&gt;permerror&lt;/code&gt;: the record is treated as invalid, SPF fails, and DMARC alignment fails with it.&lt;/p&gt;

&lt;p&gt;Nothing warns the sender. And it can affect all the mail of the domain, not only the last provider you added.&lt;/p&gt;

&lt;h2&gt;
  
  
  What counts toward the limit
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Counts as a lookup&lt;/th&gt;
&lt;th&gt;Free&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;include:&lt;/code&gt;, &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;mx&lt;/code&gt;, &lt;code&gt;ptr&lt;/code&gt;, &lt;code&gt;exists:&lt;/code&gt;, &lt;code&gt;redirect=&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;ip4:&lt;/code&gt;, &lt;code&gt;ip6:&lt;/code&gt;, &lt;code&gt;all&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two details people miss:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;mx&lt;/code&gt; is not one lookup. It costs one query for the MX records, plus one address lookup per mail server.&lt;/li&gt;
&lt;li&gt;A second limit applies to &lt;strong&gt;void lookups&lt;/strong&gt; (queries that return NXDOMAIN or no data): at most 2. Going over it is also a &lt;code&gt;permerror&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to count
&lt;/h2&gt;

&lt;p&gt;Resolve the tree by hand: follow every &lt;code&gt;include:&lt;/code&gt; and &lt;code&gt;redirect=&lt;/code&gt; into its own record, and count each mechanism that triggers a query. A record with three &lt;code&gt;include:&lt;/code&gt; entries plus &lt;code&gt;mx&lt;/code&gt; can already reach 7 once the nested includes are expanded.&lt;/p&gt;

&lt;p&gt;Here is a typical record that crosses the line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;v=spf1 include:_spf.google.com include:sendgrid.net include:servers.mcsv.net include:spf.brevo.com mx ~all
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It resolves to 11 lookups. Drop the Brevo include (a tool that is no longer used) and it falls to 9:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;v=spf1 include:_spf.google.com include:sendgrid.net include:servers.mcsv.net mx ~all
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Fixes, from simplest to most structural
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Remove unused includes.&lt;/strong&gt; Old newsletter tools and past providers pile up. This alone often brings you under 10.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replace includes with &lt;code&gt;ip4:&lt;/code&gt; / &lt;code&gt;ip6:&lt;/code&gt;&lt;/strong&gt; when a service has fixed, documented addresses that you control, for example &lt;code&gt;ip4:203.0.113.10&lt;/code&gt; instead of &lt;code&gt;include:mail.example.com&lt;/code&gt;. Do not do this for large providers such as Google or Microsoft: their ranges change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flatten the record.&lt;/strong&gt; Resolve every &lt;code&gt;include:&lt;/code&gt;, &lt;code&gt;a&lt;/code&gt;, &lt;code&gt;mx&lt;/code&gt; and &lt;code&gt;redirect=&lt;/code&gt; into IP addresses, for a cost of zero lookups. It works with every receiver, but provider IPs change, so you must re-flatten regularly (monthly is a reasonable rhythm).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Split by subdomain.&lt;/strong&gt; Send each provider from its own subdomain, with its own SPF record and its own 10-lookup budget, for example a marketing subdomain for the newsletter tool. This is the durable answer once you use more than five providers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SPF macros&lt;/strong&gt; such as &lt;code&gt;%{i}&lt;/code&gt; can build dynamic records that cut the number of static includes. It is the advanced option, and it deserves its own article.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Forgetting the lookups nested inside included records.&lt;/li&gt;
&lt;li&gt;Treating &lt;code&gt;mx&lt;/code&gt; as a single lookup.&lt;/li&gt;
&lt;li&gt;Hardcoding IPs of big providers, then never noticing when they change.&lt;/li&gt;
&lt;li&gt;Ignoring void lookups, for example an include that points to a domain that no longer exists.&lt;/li&gt;
&lt;li&gt;Flattening once and never checking again.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A short action plan
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Count your current lookups.&lt;/li&gt;
&lt;li&gt;Remove what you no longer use.&lt;/li&gt;
&lt;li&gt;Pick a fix: flattening for a quick result, subdomains for a lasting structure.&lt;/li&gt;
&lt;li&gt;Test the new record before publishing it in DNS.&lt;/li&gt;
&lt;li&gt;Re-check every month.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you want to skip the manual counting, the free &lt;a href="https://www.captaindns.com/en/tools/email-authentication/spf-record-check" rel="noopener noreferrer"&gt;SPF checker from CaptainDNS&lt;/a&gt; follows the includes, counts the lookups and detects errors, with no sign-up. The full guide, with more detail on each fix, is on the &lt;a href="https://www.captaindns.com/en/blog/spf-too-many-dns-lookups" rel="noopener noreferrer"&gt;CaptainDNS blog&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>dns</category>
      <category>email</category>
      <category>security</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
