Knowledge Base ISC Main Website Ask a Question/Contact ISC
Can I have a TXT or SPF record longer than 255 characters?
Author: ISC Support Reference Number: AA-00356 Views: 91062 Created: 2011-06-23 23:42 Last Updated: 2017-03-15 15:03 100 Rating/ 1 Voters

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.

3.1.3. Multiple Strings in a Single DNS record



As defined in [RFC1035] 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.



© 2001-2017 Internet Systems Consortium

For assistance with problems and questions for which you have not been able to find an answer in our Knowledge Base, we recommend searching our community mailing list archives and/or posting your question there (you will need to register there first for your posts to be accepted). The bind-users and the dhcp-users lists particularly have a long-standing and active membership.

ISC relies on the financial support of the community to fund the development of its open source software products. If you would like to support future product evolution and maintenance as well having peace of mind knowing that our team of experts are poised to provide you with individual technical assistance whenever you call upon them, then please consider our Professional Subscription Support services - details can be found on our main website.

Feedback 3
  • #
    [ sporkman]: Generic Error 2016-08-22 22:36

    I lost a few hours to this one. Oddly enough, in BIND 9.9.9P1, which is newer than this article, the "ran out of space" error instead is much more generic:

    "dns_rdata_fromtext: foo/example.net:18: syntax error"

    Just in case anyone else hits this KB article...

  • #
    [ Nirav Shah]: KB:- Can I have a TXT or SPF record longer than 255 characters? 2014-01-16 23:34

    KB mentions that :-

    "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."

    >> Does it means that DNS (BIND) server won't do concatenation and the application who receives this record value should performed concatenation .

    RFC-4408 does not cover this. Please advise.

    Thank you,
    Nirav Shah

  • #
    [Cathy Almond]: Re: KB:- Can I have a TXT or SPF record longer than 255 characters? 2014-01-28 13:34

    Yes - it's up to the application (SPF client code) to do the concatenation. If it doesn't do it correctly, then it's a bug. You might also experience a problem if the concatenated string ends up too long - in which case you should be able to define several different records and use the include mechanism (also documented in RFC 4408).

    If you're still having trouble with your SPF records, I recommend the bind-users community mailing list for assistance: https://lists.isc.org/mailman/listinfo/bind-users (please search the archives first - then register if you wish to post a question).

Quick Jump Menu