fail2ban拒绝蛮力垃圾邮件机器人

如果我从这里修改postfix fail2ban规则是明智的吗:

failregex = ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[<HOST>\]: 554 5\.7\.1 .*$ ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[<HOST>\]: 450 4\.7\.1 Client host rejected: cannot find your hostname, (\[\S*\]); from=<\S*> to=<\S+> proto=ESMTP helo=<\S*>$ ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[<HOST>\]: 450 4\.7\.1 : Helo command rejected: Host not found; from=<> to=<> proto=ESMTP helo= *$ ^%(__prefix_line)sNOQUEUE: reject: EHLO from \S+\[<HOST>\]: 504 5\.5\.2 <\S+>: Helo command rejected: need fully-qualified hostname; ^%(__prefix_line)sNOQUEUE: reject: VRFY from \S+\[<HOST>\]: 550 5\.1\.1 .*$ ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[<HOST>\]: 450 4\.1\.8 <\S*>: Sender address rejected: Domain not found; from=<\S*> to=<\S+> proto=ESMTP helo=<\S*>$ ^%(__prefix_line)simproper command pipelining after \S+ from [^[]*\[<HOST>\]:?$ 

通过添加以下行:

  ^%(__prefix_line)sNOQUEUE: reject: RCPT from \S+\[<HOST>\]: 550 5\.1\.1 .*$ 

因为我试图阻止这样的攻击:

 Jan 27 09:42:02 host1 postfix/smtpd[3416]: NOQUEUE: reject: RCPT from unknown[109.107.106.180]: 550 5.1.1 <[email protected]>: Recipient address rejected: User unkn own in virtual alias table; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<[109.107.106.180]> Jan 27 09:42:03 host1 postfix/smtpd[3416]: NOQUEUE: reject: RCPT from unknown[109.107.106.180]: 550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in virtual alias table; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<[109.107.106.180]> Jan 27 09:55:32 host1 postfix/smtpd[4914]: NOQUEUE: reject: RCPT from unknown[109.107.106.180]: 550 5.1.1 <[email protected]>: Recipient address rejected: User unk nown in virtual alias table; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<[109.107.106.180]> Jan 27 09:55:32 host1 postfix/smtpd[4914]: NOQUEUE: reject: RCPT from unknown[109.107.106.180]: 550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in virtual alias table; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<[109.107.106.180]> 

我担心的是,它会丢失无意的错误的电子邮件,这些电子邮件应该被弹回给错过了电子邮件地址的用户。

你有什么build议?

这种事情总是有平衡的。 一次或偶尔的失败可能是发件人的错误。 短时间内多次失败可能表明您想要实施(临时)禁令。

这就是为什么fail2ban有参数可以用来调整灵敏度。 例如,您可以设置maxretryfindtime 。 maxretry设置是在发现时间内将允许的失败尝试次数,而且地址将被禁止。

我会仔细检查一下这个文件,看看发生了什么,并且适当地设置参数。

我的build议是使用postscreen,更多信息在这里: http : //www.postfix.org/POSTSCREEN_README.html

一个postscreen(8)进程处理多个入站SMTP连接,并决定哪些客户端可以与后缀SMTP服务器进程通信。通过保留垃圾邮件,postscreen(8)服务器提供额外的保护,防止邮件服务器过载。 8)为合法客户端留下更多的SMTP服务器进程,并延迟服务器过载情况的发生。

这通过做一些聪明的检查使整个负载远离MTA。 机器人将永远不会让它直到它应该是这样的方式。

如果您的设置不允许安装postscreen,那么使用具有限制速率的策略守护进程可能会派上用场。