• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3580
  • Last Modified:

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.
0
joey40
Asked:
joey40
  • 3
  • 3
  • 2
  • +1
2 Solutions
 
AlexiosCommented:
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.
0
 
AlexiosCommented:
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.
0
 
joey40Author Commented:
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.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
AlexiosCommented:
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
0
 
footechCommented:
Instead of listing all the IPs individually, if they're contiguous use CIDR notation to define the range.
v=spf1 ip4:217.174.152.64/28 ~all

Open in new window

See here for a cheatsheet of CIDR notation.
http://bradthemad.org/tech/notes/cidr_subnets.php
0
 
DrDave242Commented:
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

0
 
joey40Author Commented:
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.
0
 
DrDave242Commented:
217.174.152.64/28 covers 217.174.152.64 through 217.174.152.79.  You'll need one more explicit address to cover 217.174.152.80, so the SPF record will look like this:

v=spf1 ip4:217.174.152.64/28 ip4:217.174.152.80 ~all

Open in new window

0
 
joey40Author Commented:
Thank you!
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now