您好我在Centos 6.5上使用postfix plus fail2ban,但我正在(我没有中继,但你去),由于某种原因fail2ban不能够切断ip和阻止它是一秒钟的6/7次进入我的/var/log/maillog
Mar 3 13:05:47 postfix/smtpd[27715]: lost connection after UNKNOWN from Unknown[209.15.212.253] Mar 3 13:05:47 postfix/smtpd[27715]: disconnect from unknown[209.15.212.253] Mar 3 13:05:47 postfix/smtpd[27715]: warning: valid_hostname: misplaced delimiter: .
我没有publishing这个机器人的IP的问题,因为它显然不是任何人的朋友,是一个目的build立垃圾邮件引擎IP(RDNS的“。”,试图创造错位的定界符漏洞)
无论如何,我有fail2banconfiguration相当正确,它通过电子邮件说,它是在sasl和后缀下运行
这里是/etc/fail2ban/jail.local
findtime = 600 bantime = 600 maxretry = 6 [sasl-iptables] enabled = true filter = postfix-sasl backend = polling action = iptables[name=sasl, port=smtp, protocol=tcp] sendmail-whois[name=sasl, [email protected]] logpath = /var/log/maillog maxretry = 5 bantime = 300 [postfix-tcpwrapper] enabled = true filter = postfix action = hostsdeny[file=/not/a/standard/path/hosts.deny] sendmail[name=Postfix, [email protected]] logpath = /var/log/maillog bantime = 300 maxretry = 6 ##the following are done in sheer desperation - no idea if they are needed [postfix] enabled = true port = smtp,ssmtp filter = postfix action = hostsdeny logpath = /var/log/maillog [perdition] enabled = true filter = perdition action = iptables-multiport[name=perdition,port="110,143,993,995"] logpath = /var/log/maillog [dovecot-pop3imap] enabled = true port = pop3,pop3s,imap,imaps filter = dovecot-pop3imap action = hostsdeny logpath = /var/log/maillog
任何人都可以帮我解释为什么这些规则仍然在/var/logs/maillog仍然被写入太多,没有人被禁止?
[/编辑] fail2ban是一个noob的一点我没有意识到(有点) /etc/fail2ban/filter.d/postfix.conf通过正则expression式的每一行 – 这里是我的/etc/fail2ban/filter.d/postfix.conf
# Fail2Ban filter for selected Postfix SMTP rejections # # [INCLUDES] # Read common prefixes. If any customizations available -- read them from # common.local before = common.conf [Definition] _daemon = postfix/smtpd 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 : Helo command rejected: Host not found; from=<> to=<> proto=ESMTP helo= *$ ^%(__prefix_line)sNOQUEUE: reject: VRFY from \S+\[<HOST>\]: 550 5\.1\.1 .*$ ignoreregex = # Author: Cyril Jaquier
你还没有告诉我们你的postfixfilter是什么,但是如果你的安装和我的一样,就是这样的
failregex = reject: RCPT from (.*)\[<HOST>\]: 554
由于您向我们显示的日志行不是这样, fail2ban不会触发它们。 如果你想让他们触发禁令,你需要编写自己的filter,匹配那些行。
但是你可能会发现,为了阻止这个单独的IP地址,把自己的iptables规则放在一个地方更有效率。 就像是
iptables -I INPUT 1 -s 209.15.212.253 -p tcp --dport 25 -j REJECT
可能会做的伎俩。