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)
|
2017-08-17 14:13:32 +00:00
|
|
|
# also, these rulesets are loaded into (nested) anchors
|
2017-10-17 18:12:48 +00:00
|
|
|
# to enable them, add as wildcard:
|
|
|
|
# anchor "f2b/*"
|
|
|
|
# or using jail names:
|
2017-08-17 14:13:32 +00:00
|
|
|
# anchor f2b {
|
2017-10-15 09:10:16 +00:00
|
|
|
# anchor name1
|
|
|
|
# anchor name2
|
2017-08-17 14:13:32 +00:00
|
|
|
# ...
|
|
|
|
# }
|
|
|
|
# to your main pf ruleset, where "namei" are the names of the jails
|
|
|
|
# which invoke this action
|
2018-01-18 13:05:22 +00:00
|
|
|
actionstart = echo "table <<tablename>-<name>> persist counters" | <pfctl> -f-
|
|
|
|
port="<port>"; if [ "$port" != "" ] && case "$port" in \{*) false;; esac; then port="{$port}"; fi
|
2017-08-17 14:13:32 +00:00
|
|
|
echo "<block> proto <protocol> from <<tablename>-<name>> to <actiontype>" | <pfctl> -f-
|
2013-04-16 11:11:06 +00:00
|
|
|
|
2017-03-29 15:44:15 +00:00
|
|
|
# Option: start_on_demand - to start action on demand
|
|
|
|
# Example: `action=pf[actionstart_on_demand=true]`
|
|
|
|
actionstart_on_demand = false
|
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
|
2017-08-16 09:58:39 +00:00
|
|
|
actionstop = <pfctl> -sr 2>/dev/null | grep -v <tablename>-<name> | <pfctl> -f-
|
2017-10-17 18:12:48 +00:00
|
|
|
%(actionflush)s
|
2017-08-16 09:58:39 +00:00
|
|
|
<pfctl> -t <tablename>-<name> -T kill
|
2013-04-16 11:11:06 +00:00
|
|
|
|
|
|
|
|
2017-10-17 18:12:48 +00:00
|
|
|
# Option: actionflush
|
|
|
|
# Notes.: command executed once to flush IPS, by shutdown (resp. by stop of the jail or this action)
|
|
|
|
# Values: CMD
|
|
|
|
#
|
|
|
|
actionflush = <pfctl> -t <tablename>-<name> -T flush
|
|
|
|
|
|
|
|
|
2013-04-16 11:11:06 +00:00
|
|
|
# Option: actioncheck
|
|
|
|
# Notes.: command executed once before each actionban command
|
|
|
|
# Values: CMD
|
|
|
|
#
|
2017-08-16 09:58:39 +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
|
|
|
|
#
|
2017-08-16 09:58:39 +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
|
2017-08-16 09:58:39 +00:00
|
|
|
actionunban = <pfctl> -t <tablename>-<name> -T delete <ip>
|
|
|
|
|
|
|
|
# Option: pfctl
|
|
|
|
#
|
|
|
|
# Use anchor as jailname to manipulate affected rulesets only.
|
|
|
|
# If more parameter expected it can be extended with `pf[pfctl="<known/pfctl> ..."]`
|
|
|
|
#
|
|
|
|
pfctl = pfctl -a f2b/<name>
|
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
|
|
|
|
2017-08-17 14:13:32 +00:00
|
|
|
# Option: block
|
|
|
|
#
|
|
|
|
# The action you want pf to take.
|
|
|
|
# Probably, you want "block quick", but adjust as needed.
|
|
|
|
block = block quick
|
|
|
|
|
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 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>]"
|
2018-01-18 13:05:22 +00:00
|
|
|
multiport = any port $port
|
2017-08-17 14:13:32 +00:00
|
|
|
|