Created
January 16, 2015 01:03
-
-
Save francismhw/4d58260288fe82ac0c5a to your computer and use it in GitHub Desktop.
/etc/fail2ban/action.d/iptables-repeater.conf fail2ban repeater
This file contains hidden or 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: Phil Hagen <phil@identityvector.com> | |
| # | |
| [Definition] | |
| # Option: actionstart | |
| # Notes.: command executed once at the start of Fail2Ban. | |
| # Values: CMD | |
| # | |
| actionstart = iptables -N fail2ban-REPEAT-<name> | |
| iptables -A fail2ban-REPEAT-<name> -j RETURN | |
| iptables -I INPUT -j fail2ban-REPEAT-<name> | |
| # set up from the static file | |
| cat /etc/fail2ban/ip.blocklist.<name> |grep -v ^\s*#|awk '{print $1}' | while read IP; do iptables -I fail2ban-REPEAT-<name> 1 -s $IP -j DROP; done | |
| # Option: actionstop | |
| # Notes.: command executed once at the end of Fail2Ban | |
| # Values: CMD | |
| # | |
| actionstop = iptables -D INPUT -j fail2ban-REPEAT-<name> | |
| iptables -F fail2ban-REPEAT-<name> | |
| iptables -X fail2ban-REPEAT-<name> | |
| # Option: actioncheck | |
| # Notes.: command executed once before each actionban command | |
| # Values: CMD | |
| # | |
| actioncheck = iptables -n -L INPUT | grep -q fail2ban-REPEAT-<name> | |
| # 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 fail2ban-REPEAT-<name> 1 -s <ip> -j DROP | |
| # also put into the static file to re-populate after a restart | |
| ! grep -Fq <ip> /etc/fail2ban/ip.blocklist.<name> && echo "<ip> # fail2ban/$( date '+%%Y-%%m-%%d %%T' ): auto-add for repeat offender" >> /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 = /bin/true | |
| [Init] | |
| # Defaut name of the chain | |
| # | |
| name = REPEAT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment