2025年2月22日 星期六

RFC 7208限制SPF的include最多是10筆

在設定DNS的SPF (Sender Policy Framework)設定的時候,使用include把一些電子郵件服務提供商的FQDN寫入SPF設定。通常include一個FQDN,填寫的內容是該ESP寄信的IP,但有些電子郵件服務提供商(ESP, E-mail Service Provider)會在裡面再填入include,變成nested lookup巢狀結構,這樣很容易就會突破lookup上限的10。這個時候用DNS查詢就會出現類似這種錯誤:

SPF PermError: too many DNS lookups

解決因為include太多的DNS永久錯誤,手動方法有兩個:

  1. SPF flattening:刪除一個include,把包含在裡面的IP直接拿出來寫
  2. 為每一個ESP創造一個subdomain,將相關的SPF的include都塞在裡面

通常會遇到這種問題,都是因為使用多個ESP。因此建議會是上述第2種設定方法:將每個ESP綁一個subdomain,這樣可以分離不同供應商,且DMARC與DKIM的設定也可以分開設定,才能降低管理難度。

對於SPF DNS lookup limit is 10這個限制有興趣的,可以參考RFC7208 section 4.6.2

Some mechanisms and modifiers (collectively, "terms") cause DNS queries at the time of evaluation, and some do not.  The following terms cause DNS queries: the "include", "a", "mx", "ptr", and "exists" mechanisms, and the "redirect" modifier.  SPF implementations MUST limit the total number of those terms to 10 during SPF evaluation, to avoid unreasonable load on the DNS.  If this limit is exceeded, the implementation MUST return "permerror".


參考資料

_EOF_

沒有留言:

張貼留言