Postfix 中的 smtpd_client_restrictions 或 smtpd_recipient_restrictions?

Postfix 中的 smtpd_client_restrictions 或 smtpd_recipient_restrictions?

我的问题是,我可怜的服务器不断遭受来自外部威胁的邮件发送尝试。每小时有数百次尝试 - 以下是来自 maillog 的其中一次尝试

Aug 15 03:43:17 xxxxxxxx courier-pop3d: Connection, ip=[::ffff:212.142.140.236]
Aug 15 03:43:17 xxxxxxxx courier-authdaemon: authpsa: short mail addresses are not allowed, got 'radiomail'
Aug 15 03:43:17 xxxxxxxx courier-pop3d: LOGIN FAILED, user=radiomail, ip=[::ffff:212.142.140.236]
Aug 15 03:43:17 xxxxxxxx courier-pop3d: authentication error: Input/output error

有问题的 IP 在 Spamhaus 上被列为威胁,但在我使用的 Barracuda 上却没有。我已将其报告给 Barracuda。幸运的是,它因“短电子邮件地址”而失败。我想阻止他们进行所有这些尝试。我尝试将 IP 放入文件 client_checks.. 中,如下所示

212.142.140.236 REJECT Your IP is spam

然后我在 main.cf 中添加了一行这样的内容

smtpd_recipient_restrictions = check_client_access hash:/etc/postfix/client_checks

结果 - 无变化

我是否将测试放在了错误的部分/空间?

我注意到有一个 client_restrictions 和一个 sender_restrictions..它们在这里

smtpd_sender_restrictions = check_sender_access, hash:/var/spool/postfix/plesk/blacklists, permit_sasl_authenticated, check_client_access, pcre:/var/spool/postfix/plesk/non_auth.re
smtpd_client_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_rbl_client b.barracudacentral.org

我发现的一件事是在 check_client_access 和 check_sender_access 后面有一个逗号。这样可以吗?

答案1

几点:

  1. smtpd_client_restrictions是放置基于 IP 地址、DNS RBL 或类似内容的限制的合理位置。它不需要知道发送者或接收者,但实际上,Postfix 不会在发送服务器发送这两者之前拒绝。

  2. 如果你使用hash:表格,你必须记住创建 Postfix 哈希表,使用postmap /etc/postfix/client_checks

  3. 您列出了来自 Courier(POP/IMAP 守护程序)的日志行。Postfix 是否使用它进行身份验证?如果没有,您可能希望查看 Postfix 日志行以查找垃圾邮件尝试。

  4. 您可能想了解一下 fail2ban,它会自动对失败的 POP、IMAP 或 SMTP 尝试进行防火墙保护。人们已经为 Courier 和 Postfix 编写了过滤器。

答案2

嗯……我一直在研究这种“暴力攻击”,并通过在防火墙中创建新规则解决了这个特定 IP(以及其他 IP)的问题。我现在可以拒绝任何我不喜欢的 IP……我的邮件日志现在可读且可用,之前我只能见树不见林。我可以看到所有有效用户登录,并正在考虑编写一些东西来提取所有有效 IP 地址,并制定“仅允许”类型的规则。

相关内容