192 |
- |
1 |
# Fail2Ban configuration file
|
|
|
2 |
#
|
|
|
3 |
# Because of the --remove-rules in stop this action requires firewalld-0.3.8+
|
|
|
4 |
|
|
|
5 |
[INCLUDES]
|
|
|
6 |
|
|
|
7 |
before = firewallcmd-common.conf
|
|
|
8 |
|
|
|
9 |
[Definition]
|
|
|
10 |
|
|
|
11 |
actionstart = firewall-cmd --direct --add-chain <family> filter f2b-<name>
|
|
|
12 |
firewall-cmd --direct --add-rule <family> filter f2b-<name> 1000 -j RETURN
|
193 |
- |
13 |
firewall-cmd --direct --add-rule <family> filter <chain> 0 -m state --state NEW -p <protocol> -m multiport --dports "$(echo '<port>' | sed s/:/-/g)" -j f2b-<name>
|
192 |
- |
14 |
|
193 |
- |
15 |
actionstop = firewall-cmd --direct --remove-rule <family> filter <chain> 0 -m state --state NEW -p <protocol> -m multiport --dports "$(echo '<port>' | sed s/:/-/g)" -j f2b-<name>
|
192 |
- |
16 |
firewall-cmd --direct --remove-rules <family> filter f2b-<name>
|
|
|
17 |
firewall-cmd --direct --remove-chain <family> filter f2b-<name>
|
|
|
18 |
|
|
|
19 |
actioncheck = firewall-cmd --direct --get-chains <family> filter | sed -e 's, ,\n,g' | grep -q 'f2b-<name>$'
|
|
|
20 |
|
|
|
21 |
actionban = firewall-cmd --direct --add-rule <family> filter f2b-<name> 0 -s <ip> -j <blocktype>
|
|
|
22 |
|
|
|
23 |
actionunban = firewall-cmd --direct --remove-rule <family> filter f2b-<name> 0 -s <ip> -j <blocktype>
|
|
|
24 |
|
|
|
25 |
# DEV NOTES:
|
|
|
26 |
#
|
|
|
27 |
# Author: Edgar Hoch
|
|
|
28 |
# Copied from iptables-new.conf and modified for use with firewalld by Edgar Hoch.
|
|
|
29 |
# It uses "firewall-cmd" instead of "iptables".
|
|
|
30 |
#
|
|
|
31 |
# Output:
|
|
|
32 |
#
|
|
|
33 |
# $ firewall-cmd --direct --add-chain ipv4 filter fail2ban-name
|
|
|
34 |
# success
|
|
|
35 |
# $ firewall-cmd --direct --add-rule ipv4 filter fail2ban-name 1000 -j RETURN
|
|
|
36 |
# success
|
|
|
37 |
# $ sudo firewall-cmd --direct --add-rule ipv4 filter INPUT_direct 0 -m state --state NEW -p tcp -m multiport --dports 22 -j fail2ban-name
|
|
|
38 |
# success
|
|
|
39 |
# $ firewall-cmd --direct --get-chains ipv4 filter
|
|
|
40 |
# fail2ban-name
|
|
|
41 |
# $ firewall-cmd --direct --get-chains ipv4 filter | od -h
|
|
|
42 |
# 0000000 6166 6c69 6232 6e61 6e2d 6d61 0a65
|
|
|
43 |
# $ firewall-cmd --direct --get-chains ipv4 filter | grep -Eq 'fail2ban-name( |$)' ; echo $?
|
|
|
44 |
# 0
|
|
|
45 |
# $ firewall-cmd -V
|
|
|
46 |
# 0.3.8
|
|
|
47 |
|