Fail2Ban - IP 表拒绝但不禁止

Fail2Ban - IP 表拒绝但不禁止

我在 Ubuntu 16 上运行了 fail2ban,并且还运行了一些 jail。

一个是http-get-dos:

在 jail.conf 中

[http-get-dos]
enabled = true
port = http,https
filter = http-get-dos
logpath = /var/log/apache2/access.log
maxretry = 100
findtime = 60
#ban for 5 minutes
bantime = 600
action = iptables[name=HTTP, port=http, protocol=tcp]

过滤文件:

# Fail2Ban configuration file
[Definition]

# Option: failregex
# Note: This regex will match any GET entry in your logs, so basically all valid and not valid entries are a match.
# You should set up in the jail.conf file, the maxretry and findtime carefully in order to avoid false positives.
failregex = ^<HOST> -.*"(GET|POST).*
# Option: ignoreregex
ignoreregex =

Fail2Ban 内的 jail 似乎运行良好 - 我刚刚通过敲击 URL 对其进行了测试,并且我的 IP 已添加到 IP 表中。

然而,我实际上并没有被封锁——IP 表 REJECT 似乎不起作用。

my.ip.address 出现在 Chain fail2ban-HTTP 中的 IP 表中,显示为 REJECT,但我没有被拒绝(仍然可以访问该网站)

iptables -nvL --行号

Chain INPUT (policy ACCEPT 2689 packets, 413K bytes)
num   pkts bytes target     prot opt in     out     source               destination         
1       68  5849 fail2ban-HTTP  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            tcp dpt:80
2     3104  575K fail2ban-apache-overflows  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            multiport dports 80,443
3     3104  575K fail2ban-apache  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            multiport dports 80,443
4      728 43824 fail2ban-ssh  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            multiport dports 22

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 3325 packets, 4380K bytes)
num   pkts bytes target     prot opt in     out     source               destination         

Chain fail2ban-HTTP (1 references)
num   pkts bytes target     prot opt in     out     source               destination         
1        0     0 REJECT     all  --  *      *       my.ip.address
     0.0.0.0/0            reject-with icmp-port-unreachable
2       68  5849 RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain fail2ban-apache (1 references)
num   pkts bytes target     prot opt in     out     source               destination         
1     3104  575K RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain fail2ban-apache-overflows (1 references)
num   pkts bytes target     prot opt in     out     source               destination         
1     3104  575K RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain fail2ban-ssh (1 references)
num   pkts bytes target     prot opt in     out     source               destination         
1      728 43824 RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0  

我想知道这是否是顺序问题 - 即全局 ACCEPT 是否优先于 IPTables 中的 fail2ban 规则。但如果这是问题所在,我不知道如何修复它,以及为什么 fail2ban 一开始没有将其放在足够高的位置。

任何建议,我都非常感谢。

答案1

您正在监控和httphttps但只http使用iptables操作禁止。使用iptables-multiport操作并禁止httphttps

action = iptables-multiport[name=HTTP, port="http,https", protocol=tcp]

相关内容