Created
June 25, 2018 07:18
-
-
Save rymdolle/04664591b9bedbd494def6ceaf744f3c to your computer and use it in GitHub Desktop.
iptables ban action for blacklist file
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: Cyril Jaquier | |
# Modified by Olle Mattsson to add blacklist file | |
# | |
[INCLUDES] | |
before = iptables-common.conf | |
[Definition] | |
# Option: actionstart | |
# Notes.: command executed once at the start of Fail2Ban. | |
# Values: CMD | |
# | |
actionstart = <iptables> -N f2b-<name> | |
<iptables> -A f2b-<name> -j <returntype> | |
<iptables> -I <chain> -p <protocol> -m multiport --dports <port> -j f2b-<name> | |
sort -V -u <file> -o <file> | |
while read IP; do <iptables> -I f2b-<name> 1 -s $IP -j <blocktype>; done < <file> | |
# 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-<name> | |
<iptables> -F f2b-<name> | |
<iptables> -X f2b-<name> | |
# Option: actioncheck | |
# Notes.: command executed once before each actionban command | |
# Values: CMD | |
# | |
actioncheck = <iptables> -n -L <chain> | grep -q 'f2b-<name>[ \t]' | |
# Option: actionban | |
# Notes.: command executed when banning an IP. Take care that the | |
# command is executed with Fail2Ban user rights. | |
# Tags: See jail.conf(5) man page | |
# Values: CMD | |
# | |
actionban = <iptables> -I f2b-<name> 1 -s <ip> -j <blocktype> | |
echo '<ip>' >> <file> | |
# Option: actionunban | |
# Notes.: command executed when unbanning an IP. Take care that the | |
# command is executed with Fail2Ban user rights. | |
# Tags: See jail.conf(5) man page | |
# Values: CMD | |
# | |
actionunban = <iptables> -D f2b-<name> -s <ip> -j <blocktype> | |
[Init] | |
file = /etc/fail2ban/ip.block |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment