我一直在使用fail2ban一段时间没有任何问题。
有一天,我决定停止fail2ban从我的默认iptables删除一个规则。 当我启动fail2ban时,它开始OK(根据命令:service fail2ban start)。
但是,当我检查iptables,我没有看到添加fail2ban链。 我检查了fail2ban日志,我发现这样的几个错误:
fail2ban.action [32091]:错误iptables -w -N f2b- iptables -w -I INPUT -p tcp -m多端口 – 端口0:65535 -j f2b- – stderr:“iptables v1.4.7:选项
-w' requires an argument\nTryiptables -h'或'iptables –help'以获取更多信息。\ niptables v1.4.7:选项-w' requires an argument\nTryiptables -h'或'iptables –help'以获取更多信息。\ niptables v1.4.7:选项-w' requires an argument\nTryiptables -h'或'iptables –help'以获取更多信息。\ n“
从这个日志看来,fail2ban正在尝试使用不存在的-w选项运行iptables。 我检查了所有的fail2banconfiguration文件,特别是在action.d目录下,并且没有一行-w选项。 这有多奇怪?
我不知道这里发生了什么,因此我无法使用fail2ban。
我感谢您的帮助。
-w选项不在iptables的1.4.7版本中,它的使用在/etc/fail2ban/action.d/iptables-common.conf文件中有解释
# Option: lockingopt # Notes.: Option was introduced to iptables to prevent multiple instances from # running concurrently and causing irratic behavior. -w was introduced # in iptables 1.4.20, so might be absent on older systems # See https://github.com/fail2ban/fail2ban/issues/1122 # Values: STRING lockingopt = -w
我会试图从上面的声明中删除-w,甚至可以发表评论,看看发生了什么事情。
检查你的yum.log,看看最近是否更新了fail2ban。 如果是的话,看看它发生的时间,并检查是否有一个yumcron工作在那个时候运行。
最好的补充是增加:
[Init] lockingopt =
在/etc/fail2ban/jail.local中
-w选项说明:
# Option: lockingopt # Notes.: Option was introduced to iptables to prevent multiple instances from # running concurrently and causing irratic behavior. -w was introduced # in iptables 1.4.20, so might be absent on older systems # See https://github.com/fail2ban/fail2ban/issues/1122 # Values: STRING
而在6.7的iptable版本是1.4.7,所以它不会工作。
更多信息在这里:
https://bugzilla.redhat.com/show_bug.cgi?id=1272681 https://github.com/fail2ban/fail2ban/issues/1122