fail2ban-apache不阻止IP

我试图configurationfail2ban,我试图login到我的web服务器无数次触发规则,看看我的iptables它似乎已经工作:

Chain fail2ban-apache (1 references) target prot opt source destination DROP all -- 192.168.1.70 0.0.0.0/0 RETURN all -- 0.0.0.0/0 0.0.0.0/0 

但是,如果我尝试从.70访问Apache服务器,我仍然可以!

有任何想法吗?

完整列表按要求:

 Chain INPUT (policy ACCEPT 100998 packets, 137858737 bytes) pkts bytes target prot opt in out source destination 0 0 fail2ban-apache tcp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 80,443 1925 322694 fail2ban-ssh tcp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 22 Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 43963 packets, 7223477 bytes) pkts bytes target prot opt in out source destination Chain fail2ban-apache (1 references) pkts bytes target prot opt in out source destination 0 0 DROP all -- * * 192.168.1.70 0.0.0.0/0 0 0 RETURN all -- * * 0.0.0.0/0 0.0.0.0/0 Chain fail2ban-ssh (1 references) pkts bytes target prot opt in out source destination 1925 322694 RETURN all -- * * 0.0.0.0/0 0.0.0.0/0 

这里发生的事情是,在多次尝试SSH之后,fail2ban规则在fail2ban-apache链上添加了192.168.1.70 ,但是这个链只在端口80和443之后。端口22仍然是允许的,因为192.168.1.70尚未添加到fail2ban-ssh链。

你会发现你不能从192.168.1.70的Web服务器发出http或https请求,但你仍然可以使用SSH。

您可能需要更改SSH规则的fail2ban操作来阻止SSH,而不是http和https。

具有更高优先级的规则之一是在防火墙达到您的阻止规则之前允许通信。 在你的规则中,阻止规则应该首先或者非常接近第一。

如果你想要阻止所有的端口出现暴力ssh攻击或apache攻击,你需要添加或编辑这些行:

 banaction = iptables-allports 

/etc/fail2ban/jail.conf[ssh][apache]行之后,或者在这里进行默认操作

 # Default banning action (eg iptables, iptables-new, # iptables-multiport, shorewall, etc) It is used to define # action_* variables. Can be overridden globally or per # section within jail.local file banaction = iptables-allports 

如果你不想阻塞所有的端口,你可以在这一行添加端口名称,数字

 [apache] enabled = true port = http,https,dns,6969 <- filter = apache-auth logpath = /var/log/apache*/*error.log maxretry = 6