192 |
- |
1 |
# Fail2Ban configuration file
|
|
|
2 |
#
|
|
|
3 |
# Author: Donald Yandt
|
|
|
4 |
#
|
|
|
5 |
# Because of the rich rule commands requires firewalld-0.3.1+
|
|
|
6 |
# This action uses firewalld rich-rules which gives you a cleaner iptables since it stores rules according to zones and not
|
|
|
7 |
# by chain. So for an example all deny rules will be listed under <zone>_deny.
|
|
|
8 |
#
|
|
|
9 |
# If you use the --permanent rule you get a xml file in /etc/firewalld/zones/<zone>.xml that can be shared and parsed easliy
|
|
|
10 |
#
|
|
|
11 |
# Example commands to view rules:
|
|
|
12 |
# firewall-cmd [--zone=<zone>] --list-rich-rules
|
|
|
13 |
# firewall-cmd [--zone=<zone>] --list-all
|
|
|
14 |
# firewall-cmd [--zone=zone] --query-rich-rule='rule'
|
|
|
15 |
|
|
|
16 |
[INCLUDES]
|
|
|
17 |
|
|
|
18 |
before = firewallcmd-common.conf
|
|
|
19 |
|
|
|
20 |
[Definition]
|
|
|
21 |
|
|
|
22 |
actionstart =
|
|
|
23 |
|
|
|
24 |
actionstop =
|
|
|
25 |
|
|
|
26 |
actioncheck =
|
|
|
27 |
|
|
|
28 |
#you can also use zones and/or service names.
|
|
|
29 |
#
|
|
|
30 |
# zone example:
|
|
|
31 |
# firewall-cmd --zone=<zone> --add-rich-rule="rule family='ipv4' source address='<ip>' port port='<port>' protocol='<protocol>' <rich-blocktype>"
|
|
|
32 |
#
|
|
|
33 |
# service name example:
|
|
|
34 |
# firewall-cmd --zone=<zone> --add-rich-rule="rule family='ipv4' source address='<ip>' service name='<service>' <rich-blocktype>"
|
|
|
35 |
#
|
|
|
36 |
# 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
|
|
|
37 |
|
|
|
38 |
actionban = ports="<port>"; for p in $(echo $ports | tr ", " " "); do firewall-cmd --add-rich-rule="rule family='<family>' source address='<ip>' port port='$p' protocol='<protocol>' <rich-blocktype>"; done
|
|
|
39 |
|
|
|
40 |
actionunban = ports="<port>"; for p in $(echo $ports | tr ", " " "); do firewall-cmd --remove-rich-rule="rule family='<family>' source address='<ip>' port port='$p' protocol='<protocol>' <rich-blocktype>"; done
|
|
|
41 |
|
|
|
42 |
|