From 4295ded9b6ea463e459abad79ee9b79fb0898666 Mon Sep 17 00:00:00 2001 From: Alexander Koeppe Date: Mon, 14 Mar 2016 20:30:19 +0100 Subject: [PATCH] improve PF action and make IPv6 aware --- config/action.d/pf.conf | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/config/action.d/pf.conf b/config/action.d/pf.conf index edcaa175..62296458 100644 --- a/config/action.d/pf.conf +++ b/config/action.d/pf.conf @@ -3,6 +3,7 @@ # OpenBSD pf ban/unban # # Author: Nick Hilliard +# Modified by: Alexander Koeppe making PF work seamless and with IPv4 and IPv6 # # @@ -12,23 +13,27 @@ # Notes.: command executed once at the start of Fail2Ban. # Values: CMD # -# we don't enable PF automatically, as it will be enabled elsewhere -actionstart = +# 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 <-> persist counters" | pfctl -f- + echo "block proto from <-> to any port " | pfctl -f- # Option: actionstop # Notes.: command executed once at the end of Fail2Ban # Values: CMD # -# we don't disable PF automatically either -actionstop = +# we only disable PF rules we've installed prior +actionstop = pfctl -sr 2>/dev/null | grep -v '-' | pfctl -f- + pfctl -t - -T flush + pfctl -t - -T kill # Option: actioncheck # Notes.: command executed once before each actionban command # Values: CMD # -actioncheck = +actioncheck = pfctl -sr | grep -q '-' # Option: actionban @@ -39,7 +44,7 @@ actioncheck = #