Created
April 4, 2018 10:10
-
-
Save daylik/90d6985a6012e1826275f1dbe3df0bd5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fail2ban configuration file | |
# | |
# Author: zEvilz <zevilz13@yandex.ru> | |
# | |
[INCLUDES] | |
before = iptables-common.conf | |
[Definition] | |
# Option: actionstart | |
# Notes.: command executed once at the start of Fail2Ban. | |
# Values: CMD | |
# | |
actionstart = <iptables> -N f2b-repeater-<name> | |
<iptables> -A f2b-repeater-<name> -j <returntype> | |
<iptables> -I <chain> -p <protocol> -m multiport --dports <port> -j f2b-repeater-<name> | |
cat /etc/fail2ban/ip.blocklist.<name> | grep -v ^\s*#|awk '{print $1}' | while read IP; do <iptables> -I f2b-repeater-<name> 1 -s $IP -j <blocktype>; done | |
# Option: actionstop | |
# Notes.: command executed once at the end of Fail2Ban | |
# Values: CMD | |
# | |
actionstop = <iptables> -D <chain> -p <protocol> -m multiport --dports <port> -j f2b-repeater-<name> | |
<iptables> -F f2b-repeater-<name> | |
<iptables> -X f2b-repeater-<name> | |
# Option: actioncheck | |
# Notes.: command executed once before each actionban command | |
# Values: CMD | |
# | |
actioncheck = <iptables> -n -L <chain> | grep -q 'f2b-repeater-<name>[ \t]' | |
# Option: actionban | |
# Notes.: command executed when banning an IP. Take care that the | |
# command is executed with Fail2Ban user rights. | |
# Tags: <ip> IP address | |
# <failures> number of failures | |
# <time> unix timestamp of the ban time | |
# Values: CMD | |
# | |
actionban = <iptables> -I f2b-repeater-<name> 1 -s <ip> -j <blocktype> | |
! grep -Fq <ip> /etc/fail2ban/ip.blocklist.<name> && echo "<ip> # $( date '+%%Y-%%m-%%d %%T' )" >> /etc/fail2ban/ip.blocklist.<name> | |
# Option: actionunban | |
# Notes.: command executed when unbanning an IP. Take care that the | |
# command is executed with Fail2Ban user rights. | |
# Tags: <ip> IP address | |
# <failures> number of failures | |
# <time> unix timestamp of the ban time | |
# Values: CMD | |
# | |
actionunban = <iptables> -D f2b-repeater-<name> -s <ip> -j <blocktype> | |
sed -i '/^<ip>.*$/d' /etc/fail2ban/ip.blocklist.<name> | |
[Init] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment