2012-01-05 23:51:03 +00:00
|
|
|
# Fail2Ban configuration file
|
|
|
|
#
|
|
|
|
# Author: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
|
|
|
|
#
|
2016-05-10 16:40:07 +00:00
|
|
|
# Modified: Alexander Koeppe <format_c@online.de>, Serg G. Brester <serg.brester@sebres.de>
|
|
|
|
# made config file IPv6 capable
|
2012-01-05 23:51:03 +00:00
|
|
|
|
2013-05-07 21:52:08 +00:00
|
|
|
[INCLUDES]
|
|
|
|
|
2020-01-16 19:08:35 +00:00
|
|
|
before = iptables.conf
|
2013-05-07 21:52:08 +00:00
|
|
|
|
2012-01-05 23:51:03 +00:00
|
|
|
[Definition]
|
|
|
|
|
2022-01-26 20:51:11 +00:00
|
|
|
_ipt_chain_rule = -m recent --update --seconds 3600 --name <iptname> -j <blocktype>
|
|
|
|
_ipt_for_proto-iter =
|
|
|
|
_ipt_for_proto-done =
|
|
|
|
|
2012-01-05 23:51:03 +00:00
|
|
|
# Option: actionstart
|
2018-09-12 14:00:40 +00:00
|
|
|
# Notes.: command executed on demand at the first ban (or at the start of Fail2Ban if actionstart_on_demand is set to false).
|
2012-01-05 23:51:03 +00:00
|
|
|
# Values: CMD
|
|
|
|
#
|
2013-03-10 22:05:33 +00:00
|
|
|
# Changing iptables rules requires root privileges. If fail2ban is
|
2012-01-05 23:51:03 +00:00
|
|
|
# configured to run as root, firewall setup can be performed by
|
|
|
|
# fail2ban automatically. However, if fail2ban is configured to run as
|
|
|
|
# a normal user, the configuration must be done by some other means
|
|
|
|
# (e.g. using static firewall configuration with the
|
|
|
|
# iptables-persistent package).
|
|
|
|
#
|
|
|
|
# Explanation of the rule below:
|
2016-05-10 16:40:07 +00:00
|
|
|
# Check if any packets coming from an IP on the <iptname>
|
2012-01-05 23:51:03 +00:00
|
|
|
# list have been seen in the last 3600 seconds. If yes, update the
|
|
|
|
# timestamp for this IP and drop the packet. If not, let the packet
|
|
|
|
# through.
|
|
|
|
#
|
2016-05-10 16:40:07 +00:00
|
|
|
# Fail2ban inserts blacklisted hosts into the <iptname> list
|
2012-01-05 23:51:03 +00:00
|
|
|
# and removes them from the list after some time, according to its
|
|
|
|
# own rules. The 3600 second timeout is independent and acts as a
|
|
|
|
# safeguard in case the fail2ban process dies unexpectedly. The
|
|
|
|
# shorter of the two timeouts actually matters.
|
2022-01-26 20:51:11 +00:00
|
|
|
actionstart = if [ `id -u` -eq 0 ];then
|
|
|
|
{ %(_ipt_check_rule)s >/dev/null 2>&1; } || { <iptables> -I <chain> %(_ipt_chain_rule)s; }
|
|
|
|
fi
|
2012-01-05 23:51:03 +00:00
|
|
|
|
2017-03-29 21:20:43 +00:00
|
|
|
# Option: actionflush
|
|
|
|
#
|
|
|
|
# [TODO] Flushing is currently not implemented for xt_recent
|
|
|
|
#
|
|
|
|
actionflush =
|
|
|
|
|
2012-01-05 23:51:03 +00:00
|
|
|
# Option: actionstop
|
2018-09-12 14:00:40 +00:00
|
|
|
# Notes.: command executed at the stop of jail (or at the end of Fail2Ban)
|
2012-01-05 23:51:03 +00:00
|
|
|
# Values: CMD
|
|
|
|
#
|
2016-05-10 16:40:07 +00:00
|
|
|
actionstop = echo / > /proc/net/xt_recent/<iptname>
|
2022-01-26 20:51:11 +00:00
|
|
|
if [ `id -u` -eq 0 ];then
|
|
|
|
<iptables> -D <chain> %(_ipt_chain_rule)s;
|
|
|
|
fi
|
2012-01-05 23:51:03 +00:00
|
|
|
|
|
|
|
# Option: actioncheck
|
2022-01-26 20:51:11 +00:00
|
|
|
# Notes.: command executed as invariant check (error by ban)
|
2012-01-05 23:51:03 +00:00
|
|
|
# Values: CMD
|
|
|
|
#
|
2022-01-26 20:51:11 +00:00
|
|
|
actioncheck = { <iptables> -C <chain> %(_ipt_chain_rule)s; } && test -e /proc/net/xt_recent/<iptname>
|
2012-01-05 23:51:03 +00:00
|
|
|
|
|
|
|
# Option: actionban
|
|
|
|
# Notes.: command executed when banning an IP. Take care that the
|
|
|
|
# command is executed with Fail2Ban user rights.
|
2013-03-16 23:52:49 +00:00
|
|
|
# Tags: See jail.conf(5) man page
|
2012-01-05 23:51:03 +00:00
|
|
|
# Values: CMD
|
|
|
|
#
|
2016-05-10 16:40:07 +00:00
|
|
|
actionban = echo +<ip> > /proc/net/xt_recent/<iptname>
|
2012-01-05 23:51:03 +00:00
|
|
|
|
|
|
|
# Option: actionunban
|
|
|
|
# Notes.: command executed when unbanning an IP. Take care that the
|
|
|
|
# command is executed with Fail2Ban user rights.
|
2013-03-16 23:52:49 +00:00
|
|
|
# Tags: See jail.conf(5) man page
|
2012-01-05 23:51:03 +00:00
|
|
|
# Values: CMD
|
|
|
|
#
|
2016-05-10 16:40:07 +00:00
|
|
|
actionunban = echo -<ip> > /proc/net/xt_recent/<iptname>
|
2012-01-05 23:51:03 +00:00
|
|
|
|
|
|
|
[Init]
|
|
|
|
|
2022-01-26 20:51:11 +00:00
|
|
|
iptname = f2b-<name>
|
2016-05-10 16:40:07 +00:00
|
|
|
|
|
|
|
[Init?family=inet6]
|
|
|
|
|
|
|
|
iptname = f2b-<name>6
|