The Ultimate SPF Record Optimization Checklist: How to Stay Within the DNS Lookup Limit and Ensure Valid Email Sending

Question:

What is the best way to optimize my SPF record, which currently has 11 DNS lookups and exceeds the maximum of 10?

Current SPF record : v=spf1 mx a include:zoho.com include:_spf.google.com include:servers.mcsv.net include:outbound.smtp.wisestamp.net ~all

This question sounds more concise and professional, and it also clarifies the goal of the optimization.

Answer:

An SPF record is a type of DNS record that specifies which mail servers are authorized to send email on behalf of a domain. It helps to prevent spoofing and phishing by verifying the sender’s identity. However, an SPF record has a limit of 10 DNS lookups, which means that it can only reference up to 10 other domains or mechanisms that require a DNS query. If an SPF record exceeds this limit, it becomes invalid and may cause email delivery issues.

In this article, we will explain how to optimize an SPF record that has 11 DNS lookups and reduce it to 10 or less. We will use the following example of an SPF record:

v=spf1 mx a include:zoho.com include:_spf.google.com include:servers.mcsv.net include:outbound.smtp.wisestamp.net ~all

This SPF record allows the domain to send email from its own mail servers (mx), any IP address that resolves to its domain name (a), and four other domains that are included (zoho.com, _spf.google.com, servers.mcsv.net, and outbound.smtp.wisestamp.net). Each of these mechanisms counts as one DNS lookup, except for the include mechanisms, which may have multiple lookups depending on the SPF records of the included domains. For example, the SPF record of zoho.com is:

v=spf1 include:zcsend.net include:mail.zoho.com ~all

This means that including zoho.com in the SPF record adds two more DNS lookups, one for zcsend.net and one for mail.zoho.com. Similarly, the SPF record of _spf.google.com is:

v=spf1 include:_netblocks.google.com include:_netblocks2.google.com include:_netblocks3.google.com ~all

This means that including _spf.google.com in the SPF record adds three more DNS lookups, one for each of the _netblocks domains. Therefore, the total number of DNS lookups for the example SPF record is:

1 (mx) + 1 (a) + 2 (zoho.com) + 3 (_spf.google.com) + 1 (servers.mcsv.net) + 1 (outbound.smtp.wisestamp.net) + 1 (~all) = 11

To optimize this SPF record, we need to eliminate one or more DNS lookups without affecting the email delivery. There are several ways to do this, but here are some common methods:

  • Remove unnecessary mechanisms: If some of the mechanisms are not needed or used for sending email, they can be removed from the SPF record. For example, if the domain does not use zoho.com for sending email, it can remove the include:zoho.com mechanism and save two DNS lookups.
  • Flatten the SPF record: Flattening an SPF record means replacing the include mechanisms with the IP addresses or ranges that they represent. This can reduce the number of DNS lookups by eliminating the need to query the included domains. However, this method requires updating the SPF record whenever the IP addresses or ranges of the included domains change. For example, the include:_spf.google.com mechanism can be flattened to:
  • ip4:35.190.247.0/24 ip4:64.233.160.0/19 ip4:66.102.0.0/20 ip4:66.249.80.0/20 ip4:72.14.192.0/18 ip4:74.125.0.0/16 ip4:108.177.8.0/21 ip4:173.194.0.0/16 ip4:209.85.128.0/17 ip4:216.58.192.0/19 ip4:216.239.32.0/19

    This reduces the number of DNS lookups by two, but it also makes the SPF record longer and harder to maintain.

  • Use a third-party service: Some third-party services offer to optimize and host the SPF records for a domain. They use various techniques such as flattening, compression, and caching to reduce the number of DNS lookups and ensure the validity of the SPF record. However, this method requires trusting the service provider and paying a fee for their service. For example, [SPFTools](https://spftools.com/) is a service that can optimize and host the SPF records for a domain.
  • Using any of these methods, the example SPF record can be optimized to have 10 or less DNS lookups. For instance, one possible optimized SPF record is:

    v=spf1 mx a ip4:35.190.247.0/24 ip4:64.233.160.0/19 ip4:66.102.0.0/20 ip4:66.249.80.0/20 ip4:72.14.192.0/18 ip4:74.125.0.0/16 ip4:108.177.8.0/21 ip4:173.194.0.0/16 ip4:209.85.128.0/17 ip4:216.58.192.0/19 ip4:216.239.32.0/19 include:servers.mcsv.net include:outbound.smtp.wisestamp.net ~all

    This SPF record has 10 DNS lookups and allows the domain to send email from the same sources as the original SPF record, except for zoho.com, which was removed.

    I

hope this article helps you to optimize your SPF record and avoid exceeding the DNS lookup limit. If you have any questions or feedback, please let me know. 😊

Leave a Reply

Your email address will not be published. Required fields are marked *

Privacy Terms Contacts About Us