2016-03-17 04:33:14 +00:00
# Fail2Ban configuration file
#
# Author: Donald Yandt
#
# Because of the rich rule commands requires firewalld-0.3.1+
# This action uses firewalld rich-rules which gives you a cleaner iptables since it stores rules according to zones and not
# by chain. So for an example all deny rules will be listed under <zone>_deny.
#
# If you use the --permanent rule you get a xml file in /etc/firewalld/zones/<zone>.xml that can be shared and parsed easliy
#
# Example commands to view rules:
# firewall-cmd [--zone=<zone>] --list-rich-rules
# firewall-cmd [--zone=<zone>] --list-all
# firewall-cmd [--zone=zone] --query-rich-rule='rule'
2016-05-14 01:36:27 +00:00
[INCLUDES]
before = firewallcmd-common.conf
2016-03-17 04:33:14 +00:00
[Definition]
actionstart =
actionstop =
actioncheck =
#you can also use zones and/or service names.
#
# zone example:
2016-05-14 01:36:27 +00:00
# firewall-cmd --zone=<zone> --add-rich-rule="rule family='ipv4' source address='<ip>' port port='<port>' protocol='<protocol>' <rich-blocktype>"
#
2016-03-17 04:33:14 +00:00
# service name example:
2016-05-14 01:36:27 +00:00
# firewall-cmd --zone=<zone> --add-rich-rule="rule family='ipv4' source address='<ip>' service name='<service>' <rich-blocktype>"
#
2016-12-11 20:13:11 +00:00
# Because rich rules can only handle single or a range of ports we must split ports and execute the command for each port. Ports can be single and ranges separated by a comma or space for an example: http, https, 22-60, 18 smtp
2016-03-17 04:33:14 +00:00
2020-09-03 14:41:23 +00:00
fwcmd_rich_rule = rule family='<family>' source address='<ip>' port port='$p' protocol='<protocol>' %(rich-suffix)s
2016-03-17 04:33:14 +00:00
2021-11-01 10:43:54 +00:00
actionban = ports="<port>"; for p in $(echo $ports | tr ", " " "); do firewall-cmd --add-rich-rule="%(fwcmd_rich_rule)s"; done
2020-09-03 14:41:23 +00:00
2021-11-01 10:43:54 +00:00
actionunban = ports="<port>"; for p in $(echo $ports | tr ", " " "); do firewall-cmd --remove-rich-rule="%(fwcmd_rich_rule)s"; done
2016-03-17 04:33:14 +00:00
2020-09-03 14:41:23 +00:00
rich-suffix = <rich-blocktype>