SPF レコードのフォーマット
Sender Policy Framework レコードのフォーマットに関する完全なリファレンス ガイドです。メカニズム、修飾子、モディファイア、そしてコピーしてそのまま使える SPF レコードの例 などの実例を紹介します。
SPF レコードの構造
v=spf1 ip4:192.0.2.1 include:_spf.google.com -all
バージョン
メカニズム
メカニズム
修飾子 + キャッチオール
メカニズム
メカニズムは、自社ドメインに代わってメールを送信することを許可されたサーバーを定義するもので、すべての SPF レコードの種類 に登場します。各メカニズムは10回の DNS ルックアップ上限にカウントされます(ip4、ip6、all を除く)。
| メカニズム | 例 | 説明 | DNS ルックアップ? |
|---|---|---|---|
| ip4 | ip4:192.0.2.0/24 | 特定の IPv4 アドレスまたは CIDR 範囲を許可する | いいえ |
| ip6 | ip6:2001:db8::/32 | 特定の IPv6 アドレスまたは範囲を許可する | いいえ |
| a | a | ドメインの A レコードの IP アドレスを許可する | はい |
| mx | mx | ドメインの MX レコードのメールサーバーを許可する | はい |
| include | include:_spf.google.com | 別のドメインの SPF レコードを参照する | はい |
| all | -all | キャッチオール メカニズム。これまでに一致しなかったすべてに一致する | いいえ |
| exists | exists:%{i}.spf.example.com | DNS の A レコードが存在するか確認する(SPF マクロで使用) | はい |
| ptr | ptr | 逆引き DNS チェック(非推奨。使用しないでください) | はい |
修飾子
修飾子はメカニズムの前に付けられ、一致が発生したときに受信サーバーが取るべきアクションを指示します。これは SPF がドメインを保護する仕組み の核心です。修飾子が指定されていない場合、+(Pass)がデフォルトとなります。
Pass
メールを受け入れます。送信者は許可されています。
Fail
メールを拒否します。送信者は許可されていません。
Soft Fail
受け入れますが、疑わしいものとしてマークします。テスト中に使用します。
Neutral
判定を行いません。SPF ポリシーがない場合と同様に扱います。
モディファイア
redirect=
SPF の処理を別のドメインの SPF レコードへ振り向けます。現在のドメインのポリシーを完全に置き換えます。
v=spf1 redirect=_spf.example.com exp=
SPF チェックが失敗したときに表示するカスタムの説明メッセージを提供します。診断に役立ちます。
v=spf1 ... -all exp=explain._spf.example.com よくある SPF レコードの例
基本 - 単一の IP
v=spf1 ip4:192.0.2.1 -all Google Workspace + 自社サーバー
v=spf1 ip4:192.0.2.1 include:_spf.google.com -all Google + Microsoft 365
v=spf1 include:_spf.google.com include:spf.protection.outlook.com -all A + MX レコード(ソフトフェイル付き)
v=spf1 a mx include:_spf.google.com ~all ベストプラクティス
-
+allは決して使わないでください。インターネット上のあらゆるサーバーを許可してしまいます - DNS ルックアップは10回未満に保ちましょう。必要なら SPF flattening を使います
- メールプロバイダーを変更する際は、SPF レコードを定期的に見直して更新しましょう
- 変更するたびに、SPF チェッカーツールでレコードをテストしましょう
- 非推奨の
ptrメカニズムは避けましょう - すべての送信元を確認できたら、
~allよりも-all(ハードフェイル)を優先しましょう
SPF レコードを手作業で管理しないでください
AutoSPF は SPF レコードのフォーマットを自動的にフラット化し、最適化します。設定は60秒で完了します。
What Our Customers Say
"AutoSPF Flattens SPF Records Seamlessly & Keeps Changes Logged - I am quite pleased with the product"
It does what it promises to do, and does it very well. I appreciate that it keeps a log of changes made, which prevents many mistakes. A client's SPF record would have way too many lookups, but AutoSPF makes that problem go away. The length of the SPF record is typically not the issue; it's the amount of lookups in the record that are. AutoSPF "flattens" the record, automatically expanding the defined lookups to IP addresses or ranges. And it auto-updates the record when the un-flattened lookups change.
Peter J.
President · Small-Business (50 or fewer emp.)
"Helped us go beyond capacity"
AutoSPF did exactly as described, it helped us get past our 10 lookup limit. Afterwards, we hit another limit regarding overall capacity and when contacted, they quickly provided us with a new solution to eliminate capacity issues entirely going forward, so now we can add as many SPF records as needed. They also provided us with a personalized support video explaining their new method in its entirety using our instance as the example.
Verified User
Financial Services · Mid-Market (51-1000 emp.)