2013-04-16 11:11:06 +00:00
|
|
|
# Fail2Ban configuration file
|
|
|
|
#
|
|
|
|
# OpenBSD pf ban/unban
|
|
|
|
#
|
|
|
|
# Author: Nick Hilliard <nick@foobar.org>
|
2016-03-14 19:30:19 +00:00
|
|
|
# Modified by: Alexander Koeppe making PF work seamless and with IPv4 and IPv6
|
2013-04-16 11:11:06 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
[Definition]
|
|
|
|
|
|
|
|
# Option: actionstart
|
|
|
|
# Notes.: command executed once at the start of Fail2Ban.
|
|
|
|
# Values: CMD
|
|
|
|
#
|
2016-03-14 19:30:19 +00:00
|
|
|
# we don't enable PF automatically; to enable run pfctl -e
|
|
|
|
# or add `pf_enable="YES"` to /etc/rc.conf (tested on FreeBSD)
|
|
|
|
actionstart = echo "table <<tablename>-<name>> persist counters" | pfctl -f-
|
2016-05-19 12:50:41 +00:00
|
|
|
echo "block proto <protocol> from <<tablename>-<name>> to <actiontype>" | pfctl -f-
|
2013-04-16 11:11:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Option: actionstop
|
|
|
|
# Notes.: command executed once at the end of Fail2Ban
|
|
|
|
# Values: CMD
|
|
|
|
#
|
2016-03-14 19:30:19 +00:00
|
|
|
# we only disable PF rules we've installed prior
|
2016-05-03 17:26:27 +00:00
|
|
|
actionstop = pfctl -sr 2>/dev/null | grep -v <tablename>-<name> | pfctl -f-
|
2016-03-14 19:30:19 +00:00
|
|
|
pfctl -t <tablename>-<name> -T flush
|
|
|
|
pfctl -t <tablename>-<name> -T kill
|
2013-04-16 11:11:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Option: actioncheck
|
|
|
|
# Notes.: command executed once before each actionban command
|
|
|
|
# Values: CMD
|
|
|
|
#
|
2016-05-03 17:26:27 +00:00
|
|
|
actioncheck = pfctl -sr | grep -q <tablename>-<name>
|
2013-04-16 11:11:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
#
|
2016-03-14 19:30:19 +00:00
|
|
|
actionban = pfctl -t <tablename>-<name> -T add <ip>
|
2013-04-16 11:11:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
# note -r option used to remove matching rule
|
2016-03-14 19:30:19 +00:00
|
|
|
actionunban = pfctl -t <tablename>-<name> -T delete <ip>
|
2013-04-16 11:11:06 +00:00
|
|
|
|
|
|
|
[Init]
|
|
|
|
# Option: tablename
|
|
|
|
# Notes.: The pf table name.
|
2013-10-14 20:29:16 +00:00
|
|
|
# Values: [ STRING ]
|
2013-04-16 11:11:06 +00:00
|
|
|
#
|
2016-05-03 17:26:27 +00:00
|
|
|
tablename = f2b
|
2013-04-16 11:11:06 +00:00
|
|
|
|
2016-03-14 19:30:19 +00:00
|
|
|
# Option: protocol
|
|
|
|
# Notes.: internally used by config reader for interpolations.
|
|
|
|
# Values: [ tcp | udp | icmp | ipv6-icmp ] Default: tcp
|
|
|
|
#
|
|
|
|
protocol = tcp
|
|
|
|
|
2016-05-17 14:27:48 +00:00
|
|
|
|
|
|
|
|
2016-05-17 19:19:34 +00:00
|
|
|
# Option: actiontype
|
|
|
|
# Notes.: defines additions to the blocking rule
|
|
|
|
# Values: leave empty to block all attempts from the host
|
2016-05-19 14:34:28 +00:00
|
|
|
# Default: Value of the multiport
|
|
|
|
actiontype = <multiport>
|
2016-05-19 12:50:41 +00:00
|
|
|
|
|
|
|
# Option: allports
|
|
|
|
# Notes.: default addition to block all ports
|
|
|
|
# Usage.: use in jail config: "banaction = pf[actiontype=<allports>]"
|
|
|
|
allports = any
|
2016-05-17 19:19:34 +00:00
|
|
|
|
|
|
|
# Option: multiport
|
|
|
|
# Notes.: addition to block access only to specific ports
|
2016-05-19 15:45:41 +00:00
|
|
|
# Usage.: use in jail config: "banaction = pf[actiontype=<multiport>]"
|
2016-05-19 12:50:41 +00:00
|
|
|
multiport = any port <port>
|