47

I do not find any guidelines regarding how to configure multiple IPs into an SPF record. So far I used (for example):

v=spf1 ip4:180.72.100.0/24 a mx ?all

But now I should add another range of IPs that are allowed, e.g.

v=spf1 ip4:180.72.100.0/24 ip4:180.20.111.0/24 a mx ?all

Is the second syntax correct? Thanks.

basZero
  • 4,129
  • 9
  • 51
  • 89

3 Answers3

33

Yes the second syntax is fine.

Have you tried using the SPF wizard? https://www.spfwizard.net/

It can quickly generate basic and complex SPF records.

Demelziraptor
  • 1,545
  • 1
  • 14
  • 20
  • Yes I was using openspf.org but I was just unsure whether I need to comma-separate the entries or newlines... Thanks! – basZero May 24 '11 at 16:24
  • Yep it's just newlines in the wizard (no commas) – Demelziraptor May 25 '11 at 00:38
  • 5
    Open SPF wizard is not more available. "The retired SPF record wizard For a long time we had a wizard utility to assist domain owners with creating SPF records for their domains. Unfortunately the wizard was not very sophisticated and often ended up generating overly complex or even incorrect records because of the difficulty of correctly explaining the concepts underlying SPF to an audience who simply wanted to create an SPF record quickly and did not care about the finer points. For this reason the wizard has been taken down. Please consult our page on the SPF record syntax instead" – Jose Nobile Jun 20 '13 at 18:51
  • @Demelziraptor I got 20 IPs to add. How do I go about doing that? – netizen0911 Oct 03 '14 at 04:50
  • 2
    @netizen0911 if they're within a subnet you can add the range (see in the question, the `/24` after the IP denoting the subnet), otherwise you can add them individually; leave the /24 out and just add the IPs separated with spaces `ipv4:192.168.0.1 ipv4:192.168.0.2` etc within your SPF record – Demelziraptor Oct 03 '14 at 16:17
  • They discontinued the wizard it is not longer available. Please update your post. – Frank G. Feb 18 '19 at 05:57
  • note that some SPF verification might fail because of too many records. – adrianTNT Apr 16 '19 at 15:12
2

Use CIDR notation such as ip4:180.72.100.0/24 for the range 180.72.100.0 - 180.72.100.255.

And you can have multiple ranges in your SPF record like so:

v=spf1 ip4:180.72.100.0/24 ip4:180.20.111.0/24 a mx ?all

You can use this calculator to determine the correct notation for your IP ranges:

https://account.arin.net/public/cidrCalculator

ProgrammerGirl
  • 3,157
  • 7
  • 45
  • 82
-1

Try this:

v=spf1 ip4:abc.de.fgh.ij ip4:klm.no.pqr.st ~all
Tomer Shetah
  • 8,413
  • 7
  • 27
  • 35