我正在使用fail2ban/firewalld来限制对Nginx服务器的类似bot的访问。 通常,相应的监狱configuration如下所示:
[nginx-botsearch] #banaction = iptables-multiport enabled = true filter = nginx-botsearch logpath = /var/log/nginx*/*access*.log maxretry = 3 bantime = 3600
这按预期工作(缺省值为firewallcmd-ipset ),即iptables -L命令在INPUT_direct链中显示一个条目:
REJECT tcp -- anywhere anywhere multiport dports http,https match-set fail2ban-nginx-botsearch src reject-with icmp-port-unreachable
与相应的fail2ban-nginx-botsearch ipset 。
但是,当bantime增加时,我注意到一个奇怪的行为。 一切正常预计bantime <= 4294967 。 当我设置bantime = 4294968并重新加载fail2ban服务时, iptables输出中的条目丢失(ipset未被创build),实际上,使用例如ab实用程序进行testing显示禁止未被强制执行。 有趣的是,使用banaction = iptables-multiport即使对于“大型”禁令也是如此。 什么可能是这种行为的原因? 我在CentOS 7上使用了fail2ban v 0.9.7。
这不是严格意义上的fail2ban相关问题,而是内核中的netfilter代码中的一个错误。 简而言之,你的ipset版本有一个timeout参数的整数溢出,所以你看到一个不可预知的行为,当它超过32位整数。
你不会看到多端口,因为它不使用这个代码,而是依靠自己的设备来跟踪超时。
这里是netfilter代码中这个问题的补丁的链接 。