У меня fail2ban работает на Ubuntu 16 с несколькими запущенными тюрьмами.
Один из них - 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 работает нормально - я просто протестировал ее, забив URL-адрес, и мой IP-адрес был добавлен в таблицы IP-адресов.
Однако на самом деле я не заблокирован - похоже, IP Tables REJECT не работает.
my.ip.address отображается в таблицах IP в цепочке fail2ban-HTTP a REJECT, но я не отклонен (все еще могу получить доступ к сайту)
iptables -nvL --line-numbers
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 превосходит правило fail2ban в IPTables. Но если это проблема, я не знаю, как ее исправить, и почему fail2ban изначально не поставил ее достаточно высоко.
Любой совет, очень ценимый.
Вы следите за обоими http
и https
но запретить только http
с помощью iptables
действие. Использовать iptables-multiport
действие и запретить оба http
и https
.
action = iptables-multiport[name=HTTP, port="http,https", protocol=tcp]