A-A+

解决fail2ban returned 200错误

2015年01月07日 经验分享 暂无评论 阅读 3,793 次

2015年的第一篇文章,记录下昨天解决的fail2ban returned 200错误。
昨天发现邮件服务器防止暴力破解的fail2ban出现异常,查看日志/var/log/fail2ban.log发现很多returned 200错误:
2015-01-06 09:32:50,623 fail2ban.actions.action: ERROR iptables -N fail2ban-pop3
iptables -A fail2ban-pop3 -j RETURN
iptables -I INPUT -p tcp --dport 1110 -j fail2ban-pop3 returned 200
2015-01-06 09:32:50,628 fail2ban.actions.action: ERROR iptables -N fail2ban-SSH
iptables -A fail2ban-SSH -j RETURN
iptables -I INPUT -p tcp --dport ssh -j fail2ban-SSH returned 200
2015-01-06 09:32:50,637 fail2ban.actions.action: ERROR iptables -N fail2ban-httpd
iptables -A fail2ban-httpd -j RETURN
iptables -I INPUT -p tcp --dport http -j fail2ban-httpd returned 200
2015-01-06 10:43:14,932 fail2ban.comm : WARNING Invalid command: ['status', 'ssh-iptables']
2015-01-06 10:49:30,640 fail2ban.actions.action: ERROR iptables -D INPUT -p tcp --dport 1110 -j fail2ban-pop3
iptables -F fail2ban-pop3
iptables -X fail2ban-pop3 returned 100
2015-01-06 10:49:30,641 fail2ban.jail : INFO Jail 'pop3' stopped
2015-01-06 10:49:31,641 fail2ban.actions.action: ERROR iptables -D INPUT -p tcp --dport http -j fail2ban-httpd
iptables -F fail2ban-httpd
iptables -X fail2ban-httpd returned 100
2015-01-06 10:49:31,642 fail2ban.jail : INFO Jail 'webmail' stopped
2015-01-06 10:49:32,647 fail2ban.actions.action: ERROR iptables -D INPUT -p tcp --dport ssh -j fail2ban-SSH
iptables -F fail2ban-SSH
iptables -X fail2ban-SSH returned 100
2015-01-06 10:49:32,647 fail2ban.jail : INFO Jail 'sshd' stopped
2015-01-06 10:49:33,643 fail2ban.jail : INFO Jail 'SMTP' stopped

解决办法:
vi/vim或其他方法修改/usr/bin/fail2ban-client这个配置文件:
1、备份好/usr/bin/fail2ban-client这个配置文件!!
# cp /usr/bin/fail2ban-client /usr/bin/fail2ban-client.bak
2、找到 def __processCmd(self, cmd, showRet = True) 这行(我的EMOS邮件系统自带的fail2ban是在142行);
3、这行下面,应该可以看到以下3行:
beautifier = Beautifier()
for c in cmd:
beautifier.setInputCmd(c)
4、在上面第二行for c in cmd:后面,增加一行:
time.sleep(0.1)
5、修改完成后,正确的是这样的:
def __processCmd(self, cmd, showRet = True):
beautifier = Beautifier()
for c in cmd:
time.sleep(0.1)
beautifier.setInputCmd(c)
6、保存修改,然后重启fail2ban:
# service fail2ban restart
7、查看日志,看是否还有returned 200错误。

最后,感谢 http://oschgan.com/drupal/index.php?q=node/52 这篇文章的指引!

author avatar

给我留言

icon_question icon_razz icon_sad icon_evil icon_exclaim icon_smile icon_redface icon_biggrin icon_surprised icon_eek icon_confused icon_cool icon_lol icon_mad icon_twisted icon_rolleyes icon_wink icon_idea icon_arrow icon_neutral icon_cry icon_mrgreen

Copyright © 2009 - 2014 一米居 | All Rights Reserved | Powered By WordPress | Theme Designed By 知更鸟 | 赣ICP备09003747号-2

用户登录

分享到: