2

I am trying to add 2 entries to a client's existing SPF record in Route 53, but I'm getting the following error:

*CharacterStringTooLong (Value is too long) encountered with '"v=spf1

ip4:27.127.198.240 ip4:52.63.207.103 include:spf.antispamcloud.com include:spf.protection.outlook.com include:transmail.net include:spf.levart.com.au include:spf.smtp2go.com include:servers.mcsv.net a:spf.inspectionmanager.com a:spf.propertyspace.com include:e.jobadder.com ~all"', Duplicate Resource Record: "google-site-verification=LoYtmNmUIF8G2zgInlqxcJDvlrV19_w5I72mD9*

The 2 entries I tried to add are:

  1. a:spf.inspectionmanager.com
  2. a:spf.propertyspace.com

Can someone please let me know the correct way to split the string to get around the 255 character limit?

Petter H
  • 3,463
Nuri
  • 21
  • 2
    You mat have another obstacle as well. There are limits to the number of resources referred to in an SPF record. My bet is you've exceeded them. – davidgo Apr 17 '20 at 08:01

2 Answers2

0

There is a blog post about splitting long > 255 char TXT records which has the following conclusion:

You'll need to split long values into parts of 255 characters and wrap your input in double quotes. You can use our DNS record splitter to do that.

Although they write about google cloud dns, the same is true also for Route53.

You can have a peek at the octodns package, which handles splitting to character length for Route53 (and others) like so:

class _ChunkedValuesMixin(_ValuesMixin):
    CHUNK_SIZE = 255
    _unescaped_semicolon_re = re.compile(r'\w;')

    def chunked_value(self, value):
        value = value.replace('"', '\\"')
        vs = [value[i:i + self.CHUNK_SIZE]
              for i in range(0, len(value), self.CHUNK_SIZE)]
        vs = '" "'.join(vs)
        return '"{}"'.format(vs)

So just splitting the text into chunks of 255 characters, and surround the chunks with double quotes " and it should work.

Petter H
  • 3,463
0

Amazon explains this here: When I try to create a TXT record using SPF syntax, I get the error ”CharacterStringTooLong (Value is too long) encountered with {Value}". How can I fix this?

The workaround is to create multiple records instead of one

You can store some validated IP addresses in a TXT SPF record and then store the rest in a second one

Swisstone
  • 6,890