Link to home
Start Free TrialLog in
Avatar of joey40
joey40

asked on

SPF Record Greater Than 255 Characters

I am trying to add an spf record using advanced DNS zone editor in cpanel. I have 17 IP address to include in the record but it brings the length over the 255 character limit and cpanel wont let me add it.
 
The record is formatted as:

"v=spf1 IP4:xxx.xxx.xxx.xx IP4:xxx.xxx.xxx.xxx etc ~all"

How do i add an spf record that is greater than 256 characters.
Avatar of Alexios Valonasis
Alexios Valonasis
Flag of Greece image

Hello

You may have more than 255 characters of data in a TXT or SPF record, but not more than 255 characters in a single string.

If you attempt to create an SPF or TXT record with a long string (>255 characters) in it, BIND will give an error (e.g. "invalid rdata format: ran out of space".)  Strings in SPF and TXT records should be no longer than 255 characters.  However to get around this limitation, per RFC 4408 a TXT or SPF record is allowed to contain multiple strings, which should be concatenated together by the reading application.  In the case of use for SPF (using either TXT or SPF RRs) the strings are concatenated together without spaces as described below.  Reassembly by other applications of multiple strings stored in TXT records might work differently.
in continuation...

From the source http://www.openspf.org/RFC_4408

3.1.3. Multiple Strings in a Single DNS record
As defined in RFC 1035 sections 3.3.14 and 3.3, a single text DNS record (either TXT or SPF RR types) can be composed of more than one string. If a published record contains multiple strings, then the record MUST be treated as if those strings are concatenated together without adding spaces. For example:

IN TXT "v=spf1 .... first" "second string..."
MUST be treated as equivalent to

IN TXT "v=spf1 .... firstsecond string..."
SPF or TXT records containing multiple strings are useful in constructing records that would exceed the 255-byte maximum length of a string within a single TXT or SPF RR record.
Avatar of joey40
joey40

ASKER

So if the long record is:

"v=spf1 IP4:217.174.152.64 IP4:217.174.152.65 IP4:217.174.152.66 IP4:217.174.152.67 IP4:217.174.152.68 IP4:217.174.152.69 IP4:217.174.152.70 IP4:217.174.152.71 IP4:217.174.152.72 IP4:217.174.152.73 IP4:217.174.152.74 IP4:217.174.152.75 IP4:217.174.152.76 IP4:217.174.152.77 IP4:217.174.152.78 IP4:217.174.152.79 IP4:217.174.152.80 ~all"

Are you saying as follows:

"v=spf1 IP4:217.174.152.64 IP4:217.174.152.65 IP4:217.174.152.66 IP4:217.174.152.67 IP4:217.174.152.68 IP4:217.174.152.69 IP4:217.174.152.70 IP4:217.174.152.71"" IP4:217.174.152.72 IP4:217.174.152.73 IP4:217.174.152.74 IP4:217.174.152.75 IP4:217.174.152.76 IP4:217.174.152.77 IP4:217.174.152.78 IP4:217.174.152.79 IP4:217.174.152.80 ~all"


I am still seeing the following error... TXT Data cannot be empty or
more than 255 characters.
You post twice the same record

Delete the space between ip's and try again

IP4:217.174.152.64IP4:217.174.152.65IP4:217.174.152.66
SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can also create host records, all with the same name, and give them the IP addresses of those servers.  Then simply add the FQDN of the host record to your SPF record with the a: mechanism.  If you give the records the name mailservers, for example, it would look like this:

v=spf1 a:mailservers.domain.com ~all

Open in new window

Avatar of joey40

ASKER

Kostasp: tried removing the spaces but still seeing the 255 character limit error.

Footech: Your solution is working but how to i cover the IP address range:

217.174.152.64 to 217.174.152.80

do i need to add anything to "v=spf1 ip4:217.174.152.64/28 ~all".

I checked the cheatsheet but i am having trouble understanding it.

Dr.Dave42..thank you for your solution. I will reserve this to use if i cant get the other to work.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of joey40

ASKER

Thank you!