將 postfix 中的 tld 列入黑名單

將 postfix 中的 tld 列入黑名單

在我的後綴設定中,我想「停用」來自特定 TLD 網域的所有傳入郵件(在我的例子中,所有以「.info」結尾的網域)。我阻止域的常用方法是使用 中的哈希文件/etc/postfix/rejected_domains,如下所示

[...]
bla.info     REJECT Spam
blubb.info   REJECT More Spam!
[...]

並在我的文件中有這段配置main.cf

# domains to be restricted
smtpd_sender_restrictions = hash:/etc/postfix/rejected_domains
reject_unauth_destinations = hash:/etc/postfix/rejected_domains

我阻止所有資訊的想法是將這些規則添加到上面的文件中:

*.info  REJECT Toooo much spam
.info   REJECT Toooo much spam

不幸的是,這似乎不起作用。

2.8.5-2~build0.10.04此處在 Ubuntu LTS 10 上使用 postfix 。

答案1

哈希用於文字(精確匹配),您想使用正規表示式或 pcre:

作為主宰指出,如果您已經有值,您想要附加這些值,您可以使用以下命令檢查現有值

postconf smtpd_sender_restrictions
postconf reject_unauth_destinations

然後你可以用以下方法覆蓋它們:

postconf -e smtpd_sender_restrictions=pcre:/etc/postfix/rejected_domains
postconf -e reject_unauth_destinations=pcre:/etc/postfix/rejected_domains

/etc/postfix/rejected_domains 的內容:

/\.info$/           REJECT All Info Domains

進而postfix reload

答案2

smtpd_helo_restrictions =
    permit_mynetworks
    permit_sasl_authenticated
    check_helo_access hash:/etc/postfix/helo_blacklist
    check_helo_access hash:/etc/postfix/helo_whitelist
    reject_invalid_helo_hostname
    reject_non_fqdn_helo_hostname
    reject_unknown_helo_hostname

在helo_blacklist中

info REJECT INFO tld blocked

執行postmap helo_blacklist

提供以 info 結尾的 helo 的伺服器將收到以下錯誤:

Helo command rejected: INFO tld blocked;

答案3

與接受的答案不同,smtpd_sender_restrictions不直接採用pcre:,但需要check_sender_access type:table.

smtpd_recipient_restrictions = 
    check_sender_access pcre:/etc/postfix/sender_access

然後,/etc/postfix/sender_access可以有:

/\.info$/  550  I do not accept mail from .info
/\.icu$/   550  https://blocked.icu/

相關內容