How to split large SPF records?
DNS TXT records are restricted to a maximum length of 255 characters. If a TXT record surpasses this limit, it may either be blocked from publication or, if it is published, it may be considered invalid.
Having a TXT-type SPF record that’s too long can cause SPF failures. A common fix is to split the long SPF record into several shorter strings within the same TXT record.
Some DNS providers automatically split the long TXT records into shorter strings within the same record. However, you might need to split the long TXT-type SPF record manually before publishing it in your DNS zone.
Below are the tips for manual splitting of long TXT-type SPF records:
1. Use Double Quotes for Each Segment
Enclose each part of the SPF record in double quotes ("..."). DNS concatenates these strings into one complete record automatically.
- Include v=spf1 Only Once
The SPF version tag v=spf1 should appear only in the first quoted string. Subsequent strings should include only the mechanisms and modifiers. - Keep Each String Under 255 Characters
Make sure no single-quoted string exceeds 255 characters to comply with DNS limits. - Split Only at Spaces
Always split the record between complete mechanisms or modifiers. Avoid breaking IP addresses, domains, or mechanisms in the middle. - Ensure Spaces Between Strings
Add a space either at the end of a string or at the beginning of the next one to separate mechanisms correctly after concatenation. - Avoid Extra Characters Between Strings
Do not add commas, backslashes, or any other characters between quoted strings—only a space if needed. - Test Your Record After Publishing
Use SPF validation tools to confirm that your split SPF record is valid and functions as expected. You can use EasyDMARC’s SPF checker tool to validate your SPF record
Here is an example of a TXT type SPF record that exceeds the DNS character limitation:
v=spf1 ip4:192.0.2.1 ip4:192.0.2.2 ip4:192.0.2.3 ip4:192.0.2.4 ip4:192.0.2.5 ip4:192.0.2.6 ip4:192.0.2.7 ip4:192.0.2.8 ip4:192.0.2.9 ip4:192.0.2.10 ip4:192.0.2.11 ip4:192.0.2.12 ip4:192.0.2.13 ip4:192.0.2.14 ip4:192.0.2.15 ip4:192.0.2.16 ip4:192.0.2.17 ip4:192.0.2.18 ip4:192.0.2.19 ip4:192.0.2.20 ~all
Below is the example of the same record split into a few strings:
"v=spf1 ip4:192.0.2.1 ip4:192.0.2.2 ip4:192.0.2.3 ip4:192.0.2.4 ip4:192.0.2.5 "
"ip4:192.0.2.6 ip4:192.0.2.7 ip4:192.0.2.8 ip4:192.0.2.9 ip4:192.0.2.10 "
"ip4:192.0.2.11 ip4:192.0.2.12 ip4:192.0.2.13 ip4:192.0.2.14 ip4:192.0.2.15 "
"ip4:192.0.2.16 ip4:192.0.2.17 ip4:192.0.2.18 ip4:192.0.2.19 ip4:192.0.2.20 ~all"
Feel free to contact EasyDMARC technical support for any additional inquiries.