Idee von http://sven.rojek.de/posts/fail2ban-iprange-mit-blackliste-blocken eingearbeitet
This commit is contained in:
67
action.d/action_ip-blacklist.conf
Normal file
67
action.d/action_ip-blacklist.conf
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
[Definition]
|
||||||
|
|
||||||
|
# Option: actionstart
|
||||||
|
# Notes.: command executed once at the start of Fail2Ban.
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstart = iptables -N fail2ban-<name>
|
||||||
|
iptables -A fail2ban-<name> -j RETURN
|
||||||
|
iptables -I <chain> -p <protocol> -j fail2ban-<name>
|
||||||
|
|
||||||
|
# Option: actionstop
|
||||||
|
# Notes.: command executed once at the end of Fail2Ban
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actionstop = iptables -D <chain> -p <protocol> -j fail2ban-<name>
|
||||||
|
iptables -F fail2ban-<name>
|
||||||
|
iptables -X fail2ban-<name>
|
||||||
|
|
||||||
|
# Option: actioncheck
|
||||||
|
# Notes.: command executed once before each actionban command
|
||||||
|
# Values: CMD
|
||||||
|
#
|
||||||
|
actioncheck = iptables -n -L <chain> | grep -q fail2ban-<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-<name> 1 -s <ip>/<mask> -j DROP
|
||||||
|
|
||||||
|
# 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 fail2ban-<name> -s <ip>/<mask> -j DROP
|
||||||
|
|
||||||
|
[Init]
|
||||||
|
|
||||||
|
# Defaut name of the chain
|
||||||
|
#
|
||||||
|
name = default
|
||||||
|
|
||||||
|
# Option: protocol
|
||||||
|
# Notes.: internally used by config reader for interpolations.
|
||||||
|
# Values: [ tcp | udp | icmp | all ] Default: all
|
||||||
|
#
|
||||||
|
protocol = all
|
||||||
|
|
||||||
|
# Option: chain
|
||||||
|
# Notes specifies the iptables chain to which the fail2ban rules should be
|
||||||
|
# added
|
||||||
|
# Values: STRING Default: INPUT
|
||||||
|
chain = INPUT
|
||||||
|
|
||||||
|
# Option: mask
|
||||||
|
# Notes.: used to ban an address-range by netmask(s) in CIDR notation.
|
||||||
|
# Values: [ 32 | 24 | 16 | 8 ] Default: 32
|
||||||
|
#
|
||||||
|
mask = 32
|
||||||
20
fail2ban.blacklist
Normal file
20
fail2ban.blacklist
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
########################################
|
||||||
|
#
|
||||||
|
# Single IP Example:
|
||||||
|
# 10.10.10.10 [2015-01-01 12:00:00]
|
||||||
|
# 10.10.10.10/32 [2015-01-01 12:00:00]
|
||||||
|
#
|
||||||
|
#########################################
|
||||||
|
#
|
||||||
|
# IP Range Options:
|
||||||
|
# 10.10.10.10/24 = 10.10.10.*
|
||||||
|
# 10.10.10.10/16 = 10.10.*.*
|
||||||
|
# 10.10.10.10/8 = 10.*.*.*
|
||||||
|
#
|
||||||
|
#########################################
|
||||||
|
#
|
||||||
|
# IP Range Examples:
|
||||||
|
# 10.10.10.10/16 [2015-01-01 12:00:00]
|
||||||
|
# 10.10.10.10/24 [2015-01-01 12:00:00]
|
||||||
|
#
|
||||||
|
#########################################
|
||||||
15
filter.d/filter_ip-blacklist.conf
Normal file
15
filter.d/filter_ip-blacklist.conf
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[Definition]
|
||||||
|
|
||||||
|
# Option: failregex
|
||||||
|
# Notes : Detection of blocked ip addresses.
|
||||||
|
# Values: TEXT
|
||||||
|
#
|
||||||
|
|
||||||
|
failregex = ^<HOST>(/32.*|[^/].*)?$
|
||||||
|
|
||||||
|
# Option: ignoreregex
|
||||||
|
# Notes : Regex to ignore.
|
||||||
|
# Values: TEXT
|
||||||
|
#
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
15
filter.d/filter_ip-blacklist16.conf
Normal file
15
filter.d/filter_ip-blacklist16.conf
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[Definition]
|
||||||
|
|
||||||
|
# Option: failregex
|
||||||
|
# Notes : Detection of blocked ip addresses.
|
||||||
|
# Values: TEXT
|
||||||
|
#
|
||||||
|
|
||||||
|
failregex = ^<HOST>/16.*$
|
||||||
|
|
||||||
|
# Option: ignoreregex
|
||||||
|
# Notes : Regex to ignore.
|
||||||
|
# Values: TEXT
|
||||||
|
#
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
15
filter.d/filter_ip-blacklist24.conf
Normal file
15
filter.d/filter_ip-blacklist24.conf
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[Definition]
|
||||||
|
|
||||||
|
# Option: failregex
|
||||||
|
# Notes : Detection of blocked ip addresses.
|
||||||
|
# Values: TEXT
|
||||||
|
#
|
||||||
|
|
||||||
|
failregex = ^<HOST>/24.*$
|
||||||
|
|
||||||
|
# Option: ignoreregex
|
||||||
|
# Notes : Regex to ignore.
|
||||||
|
# Values: TEXT
|
||||||
|
#
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
15
filter.d/filter_ip-blacklist8.conf
Normal file
15
filter.d/filter_ip-blacklist8.conf
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[Definition]
|
||||||
|
|
||||||
|
# Option: failregex
|
||||||
|
# Notes : Detection of blocked ip addresses.
|
||||||
|
# Values: TEXT
|
||||||
|
#
|
||||||
|
|
||||||
|
failregex = ^<HOST>/8.*$
|
||||||
|
|
||||||
|
# Option: ignoreregex
|
||||||
|
# Notes : Regex to ignore.
|
||||||
|
# Values: TEXT
|
||||||
|
#
|
||||||
|
|
||||||
|
ignoreregex =
|
||||||
@@ -31,7 +31,7 @@ enabled = true
|
|||||||
port = anyport
|
port = anyport
|
||||||
action = action_ip-blacklist
|
action = action_ip-blacklist
|
||||||
filter = filter_ip-blacklist
|
filter = filter_ip-blacklist
|
||||||
logpath = /var/log/fail2ban-blacklist
|
logpath = /var/log/fail2ban.blacklist
|
||||||
maxretry = 0
|
maxretry = 0
|
||||||
findtime = 15552000
|
findtime = 15552000
|
||||||
bantime = -1
|
bantime = -1
|
||||||
@@ -41,7 +41,7 @@ enabled = true
|
|||||||
port = anyport
|
port = anyport
|
||||||
action = action_ip-blacklist[mask=24]
|
action = action_ip-blacklist[mask=24]
|
||||||
filter = filter_ip-blacklist24
|
filter = filter_ip-blacklist24
|
||||||
logpath = /var/log/fail2ban-blacklist
|
logpath = /var/log/fail2ban.blacklist
|
||||||
maxretry = 0
|
maxretry = 0
|
||||||
findtime = 15552000
|
findtime = 15552000
|
||||||
bantime = -1
|
bantime = -1
|
||||||
@@ -51,7 +51,7 @@ enabled = true
|
|||||||
port = anyport
|
port = anyport
|
||||||
action = action_ip-blacklist[mask=16]
|
action = action_ip-blacklist[mask=16]
|
||||||
filter = filter_ip-blacklist16
|
filter = filter_ip-blacklist16
|
||||||
logpath = /var/log/fail2ban-blacklist
|
logpath = /var/log/fail2ban.blacklist
|
||||||
maxretry = 0
|
maxretry = 0
|
||||||
findtime = 15552000
|
findtime = 15552000
|
||||||
bantime = -1
|
bantime = -1
|
||||||
@@ -61,7 +61,7 @@ enabled = true
|
|||||||
port = anyport
|
port = anyport
|
||||||
action = action_ip-blacklist[mask=8]
|
action = action_ip-blacklist[mask=8]
|
||||||
filter = filter_ip-blacklist8
|
filter = filter_ip-blacklist8
|
||||||
logpath = /var/log/fail2ban-blacklist
|
logpath = /var/log/fail2ban.blacklist
|
||||||
maxretry = 0
|
maxretry = 0
|
||||||
findtime = 15552000
|
findtime = 15552000
|
||||||
bantime = -1
|
bantime = -1
|
||||||
|
|||||||
Reference in New Issue
Block a user