Include Multiple Server IPs in one SPF record

When you have one mail server, you can use the mail server IP in your spf record

client_domain.com. TXT "v=spf1 ip4:10.0.1.1 ~all"

When you have multiple mail servers or multiple IPs on one mail server, you have to do this

client_domain.com. TXT "v=spf1 ip4:10.0.1.1 ip4:10.0.1.2 ip4:10.0.1.3 ip4:10.0.1.4 ip4:10.0.1.5 ~all"

This is not convenient and cumbersome especially when you will adding more servers and migrate client from older server to new one.

To make it simple, you can create one spf record using a subdomain to include all mail server IPs.

client_domain.com. TXT "v=spf1 include:_spf.cpanelcares.com ~all"

To make above record work, you need to add the TXT record like follows to your domain first:

Main spf record which includes all mail servers:

_spf.cpanelcares.com TXT "v=spf1 include:_netblocks1.cpanelcares.com include:_netblocks2.cpanelcares.com ~all"

The _netblocks1 subdomain includes all shared server IPs:
_netblocks.cpanelcares.com TXT "v=spf1 ip4:10.0.1.0/24 ip4:10.0.2.0/24 ~all"

The _netblocks2 subdomain includes all VPS server IPs:
_netblocks2.cpanelcares.com TXT "v=spf1 ip4:65.61.209.0/24 ~all"

PS: Inspired by Google.com’s spf record.

google.com. 3599 IN TXT "v=spf1 include:_spf.google.com ~all"

_spf.google.com. 299 IN TXT "v=spf1 include:_netblocks.google.com include:_netblocks2.google.com include:_netblocks3.google.com ~all"

_netblocks.google.com. 3599 IN TXT "v=spf1 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 ~all"