From 30e7e28e76a31e4250046a26bd55af6e3e56eb39 Mon Sep 17 00:00:00 2001 From: k0ka Date: Sat, 2 Jan 2021 21:55:24 +0100 Subject: [PATCH] new parameter `table` for firewallcmd-* --- config/action.d/firewallcmd-allports.conf | 18 +++++++++--------- config/action.d/firewallcmd-common.conf | 6 ++++++ config/action.d/firewallcmd-ipset.conf | 4 ++-- config/action.d/firewallcmd-multiport.conf | 18 +++++++++--------- config/action.d/firewallcmd-new.conf | 18 +++++++++--------- 5 files changed, 35 insertions(+), 29 deletions(-) diff --git a/config/action.d/firewallcmd-allports.conf b/config/action.d/firewallcmd-allports.conf index de0e7f91..00570c85 100644 --- a/config/action.d/firewallcmd-allports.conf +++ b/config/action.d/firewallcmd-allports.conf @@ -10,22 +10,22 @@ before = firewallcmd-common.conf [Definition] -actionstart = firewall-cmd --direct --add-chain filter f2b- - firewall-cmd --direct --add-rule filter f2b- 1000 -j RETURN - firewall-cmd --direct --add-rule filter 0 -j f2b- +actionstart = firewall-cmd --direct --add-chain f2b- + firewall-cmd --direct --add-rule
f2b- 1000 -j RETURN + firewall-cmd --direct --add-rule
0 -j f2b- -actionstop = firewall-cmd --direct --remove-rule filter 0 -j f2b- - firewall-cmd --direct --remove-rules filter f2b- - firewall-cmd --direct --remove-chain filter f2b- +actionstop = firewall-cmd --direct --remove-rule
0 -j f2b- + firewall-cmd --direct --remove-rules
f2b- + firewall-cmd --direct --remove-chain
f2b- # Example actioncheck: firewall-cmd --direct --get-chains ipv4 filter | sed -e 's, ,\n,g' | grep -q '^f2b-recidive$' -actioncheck = firewall-cmd --direct --get-chains filter | sed -e 's, ,\n,g' | grep -q '^f2b-$' +actioncheck = firewall-cmd --direct --get-chains
| sed -e 's, ,\n,g' | grep -q '^f2b-$' -actionban = firewall-cmd --direct --add-rule filter f2b- 0 -s -j +actionban = firewall-cmd --direct --add-rule
f2b- 0 -s -j -actionunban = firewall-cmd --direct --remove-rule filter f2b- 0 -s -j +actionunban = firewall-cmd --direct --remove-rule
f2b- 0 -s -j # DEV NOTES: # diff --git a/config/action.d/firewallcmd-common.conf b/config/action.d/firewallcmd-common.conf index 4abe5318..4cf76c6f 100644 --- a/config/action.d/firewallcmd-common.conf +++ b/config/action.d/firewallcmd-common.conf @@ -25,6 +25,12 @@ protocol = tcp # Values: STRING family = ipv4 +# Option: table +# Notes specifies the firewalld table to which the Fail2Ban rules should be +# added +# Values: [filter | nat | mangle | raw] Default: filter +table = filter + # Option: chain # Notes specifies the firewalld chain to which the Fail2Ban rules should be # added diff --git a/config/action.d/firewallcmd-ipset.conf b/config/action.d/firewallcmd-ipset.conf index c89a0243..75e79704 100644 --- a/config/action.d/firewallcmd-ipset.conf +++ b/config/action.d/firewallcmd-ipset.conf @@ -19,11 +19,11 @@ before = firewallcmd-common.conf [Definition] actionstart = ipset create hash:ip timeout - firewall-cmd --direct --add-rule filter 0 -m set --match-set src -j + firewall-cmd --direct --add-rule
0 -m set --match-set src -j actionflush = ipset flush -actionstop = firewall-cmd --direct --remove-rule filter 0 -m set --match-set src -j +actionstop = firewall-cmd --direct --remove-rule
0 -m set --match-set src -j ipset destroy diff --git a/config/action.d/firewallcmd-multiport.conf b/config/action.d/firewallcmd-multiport.conf index 0c401f1b..6dc22614 100644 --- a/config/action.d/firewallcmd-multiport.conf +++ b/config/action.d/firewallcmd-multiport.conf @@ -9,18 +9,18 @@ before = firewallcmd-common.conf [Definition] -actionstart = firewall-cmd --direct --add-chain filter f2b- - firewall-cmd --direct --add-rule filter f2b- 1000 -j RETURN - firewall-cmd --direct --add-rule filter 0 -m conntrack --ctstate NEW -p -m multiport --dports "$(echo '' | sed s/:/-/g)" -j f2b- +actionstart = firewall-cmd --direct --add-chain
f2b- + firewall-cmd --direct --add-rule
f2b- 1000 -j RETURN + firewall-cmd --direct --add-rule
0 -m conntrack --ctstate NEW -p -m multiport --dports "$(echo '' | sed s/:/-/g)" -j f2b- -actionstop = firewall-cmd --direct --remove-rule filter 0 -m conntrack --ctstate NEW -p -m multiport --dports "$(echo '' | sed s/:/-/g)" -j f2b- - firewall-cmd --direct --remove-rules filter f2b- - firewall-cmd --direct --remove-chain filter f2b- +actionstop = firewall-cmd --direct --remove-rule
0 -m conntrack --ctstate NEW -p -m multiport --dports "$(echo '' | sed s/:/-/g)" -j f2b- + firewall-cmd --direct --remove-rules
f2b- + firewall-cmd --direct --remove-chain
f2b- # Example actioncheck: firewall-cmd --direct --get-chains ipv4 filter | sed -e 's, ,\n,g' | grep -q '^f2b-apache-modsecurity$' -actioncheck = firewall-cmd --direct --get-chains filter | sed -e 's, ,\n,g' | grep -q '^f2b-$' +actioncheck = firewall-cmd --direct --get-chains
| sed -e 's, ,\n,g' | grep -q '^f2b-$' -actionban = firewall-cmd --direct --add-rule filter f2b- 0 -s -j +actionban = firewall-cmd --direct --add-rule
f2b- 0 -s -j -actionunban = firewall-cmd --direct --remove-rule filter f2b- 0 -s -j +actionunban = firewall-cmd --direct --remove-rule
f2b- 0 -s -j diff --git a/config/action.d/firewallcmd-new.conf b/config/action.d/firewallcmd-new.conf index 7b08603c..260d2f10 100644 --- a/config/action.d/firewallcmd-new.conf +++ b/config/action.d/firewallcmd-new.conf @@ -8,19 +8,19 @@ before = firewallcmd-common.conf [Definition] -actionstart = firewall-cmd --direct --add-chain filter f2b- - firewall-cmd --direct --add-rule filter f2b- 1000 -j RETURN - firewall-cmd --direct --add-rule filter 0 -m state --state NEW -p -m multiport --dports "$(echo '' | sed s/:/-/g)" -j f2b- +actionstart = firewall-cmd --direct --add-chain
f2b- + firewall-cmd --direct --add-rule
f2b- 1000 -j RETURN + firewall-cmd --direct --add-rule
0 -m state --state NEW -p -m multiport --dports "$(echo '' | sed s/:/-/g)" -j f2b- -actionstop = firewall-cmd --direct --remove-rule filter 0 -m state --state NEW -p -m multiport --dports "$(echo '' | sed s/:/-/g)" -j f2b- - firewall-cmd --direct --remove-rules filter f2b- - firewall-cmd --direct --remove-chain filter f2b- +actionstop = firewall-cmd --direct --remove-rule
0 -m state --state NEW -p -m multiport --dports "$(echo '' | sed s/:/-/g)" -j f2b- + firewall-cmd --direct --remove-rules
f2b- + firewall-cmd --direct --remove-chain
f2b- -actioncheck = firewall-cmd --direct --get-chains filter | sed -e 's, ,\n,g' | grep -q 'f2b-$' +actioncheck = firewall-cmd --direct --get-chains
| sed -e 's, ,\n,g' | grep -q 'f2b-$' -actionban = firewall-cmd --direct --add-rule filter f2b- 0 -s -j +actionban = firewall-cmd --direct --add-rule
f2b- 0 -s -j -actionunban = firewall-cmd --direct --remove-rule filter f2b- 0 -s -j +actionunban = firewall-cmd --direct --remove-rule
f2b- 0 -s -j # DEV NOTES: #