| 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 and all log rules under <zone>_log.
|
|
|
8 |
#
|
|
|
9 |
# Also this action logs banned access attempts so you can filter that and increase ban time for offenders.
|
|
|
10 |
#
|
|
|
11 |
# If you use the --permanent rule you get a xml file in /etc/firewalld/zones/<zone>.xml that can be shared and parsed easliy
|
|
|
12 |
#
|
|
|
13 |
# Example commands to view rules:
|
|
|
14 |
# firewall-cmd [--zone=<zone>] --list-rich-rules
|
|
|
15 |
# firewall-cmd [--zone=<zone>] --list-all
|
|
|
16 |
# firewall-cmd [--zone=zone] --query-rich-rule='rule'
|
|
|
17 |
|
|
|
18 |
[INCLUDES]
|
|
|
19 |
|
|
|
20 |
before = firewallcmd-common.conf
|
|
|
21 |
|
|
|
22 |
[Definition]
|
|
|
23 |
|
|
|
24 |
actionstart =
|
|
|
25 |
|
|
|
26 |
actionstop =
|
|
|
27 |
|
|
|
28 |
actioncheck =
|
|
|
29 |
|
|
|
30 |
# you can also use zones and/or service names.
|
|
|
31 |
#
|
|
|
32 |
# zone example:
|
|
|
33 |
# firewall-cmd --zone=<zone> --add-rich-rule="rule family='<family>' source address='<ip>' port port='<port>' protocol='<protocol>' log prefix='f2b-<name>' level='<level>' limit value='<rate>/m' <rich-blocktype>"
|
|
|
34 |
#
|
|
|
35 |
# service name example:
|
|
|
36 |
# firewall-cmd --zone=<zone> --add-rich-rule="rule family='<family>' source address='<ip>' service name='<service>' log prefix='f2b-<name>' level='<level>' limit value='<rate>/m' <rich-blocktype>"
|
|
|
37 |
#
|
|
|
38 |
# 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
|
|
|
39 |
|
|
|
40 |
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>' log prefix='f2b-<name>' level='<level>' limit value='<rate>/m' <rich-blocktype>"; done
|
|
|
41 |
|
|
|
42 |
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>' log prefix='f2b-<name>' level='<level>' limit value='<rate>/m' <rich-blocktype>"; done
|
|
|
43 |
|
|
|
44 |
[Init]
|
|
|
45 |
|
|
|
46 |
# log levels are "emerg", "alert", "crit", "error", "warning", "notice", "info" or "debug"
|
|
|
47 |
level = info
|
|
|
48 |
|
|
|
49 |
# log rate per minute
|
|
|
50 |
rate = 1
|
|
|
51 |
|