Email and Cyber Security · #25

Online SPF Record Generator

Builds an SPF TXT record draft from your sending servers in the right order and shows the DNS lookup cost.

  • Data is processed in your browser and not sent to a server

Tool

One address or CIDR per line.

One domain per line; no need to type 'include:'.

Allow the domain's A/AAAA addresses to send.

Allow the MX servers to send.

What to do with senders not listed.

What does this tool do?

An SPF record lists the servers allowed to send mail for your domain. The tool turns the IPs, includes and a/mx mechanisms you enter into a syntactically correct record, counts the known DNS lookup cost and outputs the record ready to paste into a DNS zone. Nothing is written to DNS.

How to use it

  1. Enter fixed sending IPv4/IPv6 addresses or blocks, one per line.
  2. Add include domains of sending services (e.g. spf.protection.outlook.com).
  3. Tick a and mx if needed, choose the all qualifier and press Calculate.

Fields

IPv4 addresses / blocks
One address or CIDR per line.
IPv6 addresses / blocks
Include domains
One domain per line; no need to type 'include:'.
a mechanism
Allow the domain's A/AAAA addresses to send.
mx mechanism
Allow the MX servers to send.
all qualifier
What to do with senders not listed.

Worked example

InputValue
IPv4 addresses / blocks
203.0.113.25
198.51.100.0/24
Include domains
spf.protection.outlook.com
all qualifier~all (softfail)

Expected result: v=spf1 ip4:203.0.113.25 ip4:198.51.100.0/24 include:spf.protection.outlook.com ~all — 1 DNS lookup (excluding the include's nested lookups).

ip4 and ip6 need no DNS lookups; only include, a, mx, exists and redirect count. The Microsoft 365 include may perform further lookups, so verify the total with the SPF Record Checker after publishing. Switch from ~all to -all once the migration is complete.

Method and assumptions

Mechanisms are written in this order: a, mx, ip4, ip6, include, all. Order does not change the result, but lookup-free ip4/ip6 terms match early.

CIDRs with host bits are converted to the network. A record longer than 255 characters must be split into several quoted strings within one TXT record; the tool also outputs zone file format.

Using the result and troubleshooting

Add the record as the root (@) TXT record at your DNS provider; do not create a second SPF record at the same name, edit the existing one.

After publishing, wait for the TTL and check the 10-lookup limit and nested includes with the SPF Record Checker.

Limits and common mistakes

  • The lookup cost of include targets cannot be known offline; verify the total after publishing.
  • Nothing is written to DNS; macros and exists are not supported.

Frequently asked questions

Should I use -all or ~all?

With DMARC, receivers decide mostly on DMARC; still, -all is the clearer signal once all senders are listed. Start with ~all during a migration and watch the reports.

Related tools and service

  • SPF Record CheckerExpands an SPF record with its include and redirect chain, counts the DNS lookup budget and shows structural errors.

Related service: Email Security and Phishing Protection

Cybersecurity online tools · See all online tools