Suped

What SPF mechanism should be used for a specific IP address?

When you're setting up Sender Policy Framework (SPF), you're essentially creating a list of approved senders for your domain. As Kinsta puts it, an SPF record is a DNS TXT record that contains a list of all the authorized mail servers for your website. This is done using a series of 'mechanisms' in your SPF record. Each mechanism defines a specific type of authorized sender. A common question I see is how to authorize a specific IP address. The answer comes down to choosing the right tool, or in this case, the right mechanism for the job.

There are two primary mechanisms you might consider for this task: ip4 and a. While both can technically achieve the goal, one is far more direct and efficient than the other.

Suped DMARC monitor
Free forever, no credit card required
Get started for free
Trusted by teams securing millions of inboxes
Company logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logo

The direct approach: the ip4 mechanism

If you have a specific IPv4 address you need to authorize, the ip4 mechanism is your best bet. It is the most explicit and straightforward way to handle this situation. As the name suggests, it's designed specifically for listing IP addresses.

autospf.com logo
AutoSPF says:
Visit website
'ip4' mechanism. The 'ip4' mechanism is used to explicitly authorize an IPv4 address (or range) to send emails on behalf of your domain.

Using this mechanism is simple. You just add ip4: followed by the IP address to your SPF record. For example, if your mail server's IP address is 192.0.2.1, your SPF record would look something like this:

v=spf1 ip4:192.0.2.1 -all

The major advantage here is performance. When a receiving mail server checks your SPF record, it sees the IP address right there. There's no need for any additional DNS lookups to validate the sender. It's a clean, one-step process. This directness makes ip4 the most efficient and recommended mechanism for authorizing a specific IP address. Of course, if you're working with an IPv6 address, you'd use the ip6 mechanism in the same way.

What about the 'a' mechanism?

The other mechanism you might see mentioned is a. This mechanism works by checking the sender's IP address against the A record of a domain. If you simply use a in your SPF record, it tells receiving servers to look up the A record for your domain (the one the SPF record is on) and see if the sending IP matches.

community.spiceworks.com logo
Spiceworks Community says:
Visit website
Using “a” alone in an spf record only includes the IP address(es), of the domain root (domain.com)…NOT the IP address of every A record in the ...

You can also specify a particular hostname, like a:mail.example.com. This is useful if your sending IP is tied to a specific hostname and you expect that IP to change. In that scenario, you'd only need to update the A record for mail.example.com rather than editing your SPF record. However, this flexibility comes at the cost of an additional DNS lookup, making it less efficient than the ip4 mechanism.

Comparing ip4 and a for a specific IP

So, when you're deciding which to use for a single, specific IP address, here's how I break it down:

  • Use the ip4 mechanism if: The IP address is static and unlikely to change. This is the most common scenario for dedicated mail servers. It's the most efficient, direct, and unambiguous way to grant permission.
  • Use the a mechanism if: The sending IP is explicitly tied to a hostname (e.g., mail.yourdomain.com) and you anticipate the IP address for that hostname might change. Using the a mechanism allows you to manage the IP change at the DNS A record level, without touching your SPF record. This is a more advanced use case.

My final recommendation

For the vast majority of cases where you need to authorize a single, specific IP address, the ip4 mechanism is the correct choice. It is the clearest, most performant, and most direct method. It removes any ambiguity and reduces the processing load on receiving mail servers by avoiding unnecessary DNS lookups. While the a mechanism has its purpose for managing dynamic IPs via hostnames, using ip4 for a static IP is a foundational best practice for creating a clean and effective SPF record.

Start improving your email deliverability today

Get started