Line 2... |
Line 2... |
2 |
#
|
2 |
#
|
3 |
# Because of the --remove-rules in stop this action requires firewalld-0.3.8+
|
3 |
# Because of the --remove-rules in stop this action requires firewalld-0.3.8+
|
4 |
|
4 |
|
5 |
[INCLUDES]
|
5 |
[INCLUDES]
|
6 |
|
6 |
|
7 |
before = iptables-blocktype.conf
|
7 |
before = iptables-common.conf
|
8 |
|
8 |
|
9 |
[Definition]
|
9 |
[Definition]
|
10 |
|
10 |
|
11 |
actionstart = firewall-cmd --direct --add-chain ipv4 filter fail2ban-<name>
|
11 |
actionstart = firewall-cmd --direct --add-chain ipv4 filter f2b-<name>
|
12 |
firewall-cmd --direct --add-rule ipv4 filter fail2ban-<name> 1000 -j RETURN
|
12 |
firewall-cmd --direct --add-rule ipv4 filter f2b-<name> 1000 -j RETURN
|
13 |
firewall-cmd --direct --add-rule ipv4 filter <chain> 0 -m state --state NEW -p <protocol> --dport <port> -j fail2ban-<name>
|
13 |
firewall-cmd --direct --add-rule ipv4 filter <chain> 0 -m state --state NEW -p <protocol> -m multiport --dports <port> -j f2b-<name>
|
14 |
|
14 |
|
15 |
actionstop = firewall-cmd --direct --remove-rule ipv4 filter <chain> 0 -m state --state NEW -p <protocol> --dport <port> -j fail2ban-<name>
|
15 |
actionstop = firewall-cmd --direct --remove-rule ipv4 filter <chain> 0 -m state --state NEW -p <protocol> -m multiport --dports <port> -j f2b-<name>
|
16 |
firewall-cmd --direct --remove-rules ipv4 filter fail2ban-<name>
|
16 |
firewall-cmd --direct --remove-rules ipv4 filter f2b-<name>
|
17 |
firewall-cmd --direct --remove-chain ipv4 filter fail2ban-<name>
|
17 |
firewall-cmd --direct --remove-chain ipv4 filter f2b-<name>
|
18 |
|
18 |
|
19 |
actioncheck = firewall-cmd --direct --get-chains ipv4 filter | grep -q '^fail2ban-<name>$'
|
19 |
actioncheck = firewall-cmd --direct --get-chains ipv4 filter | grep -q 'f2b-<name>$'
|
20 |
|
20 |
|
21 |
actionban = firewall-cmd --direct --add-rule ipv4 filter fail2ban-<name> 0 -s <ip> -j <blocktype>
|
21 |
actionban = firewall-cmd --direct --add-rule ipv4 filter f2b-<name> 0 -s <ip> -j <blocktype>
|
22 |
|
22 |
|
23 |
actionunban = firewall-cmd --direct --remove-rule ipv4 filter fail2ban-<name> 0 -s <ip> -j <blocktype>
|
23 |
actionunban = firewall-cmd --direct --remove-rule ipv4 filter f2b-<name> 0 -s <ip> -j <blocktype>
|
24 |
|
24 |
|
25 |
[Init]
|
25 |
[Init]
|
26 |
|
- |
|
27 |
# Default name of the chain
|
- |
|
28 |
#
|
- |
|
29 |
name = default
|
- |
|
30 |
|
- |
|
31 |
# Option: port
|
- |
|
32 |
# Notes.: specifies port to monitor
|
- |
|
33 |
# Values: [ NUM | STRING ]
|
- |
|
34 |
#
|
- |
|
35 |
port = ssh
|
- |
|
36 |
|
- |
|
37 |
# Option: protocol
|
- |
|
38 |
# Notes.: internally used by config reader for interpolations.
|
- |
|
39 |
# Values: [ tcp | udp | icmp | all ]
|
- |
|
40 |
#
|
- |
|
41 |
protocol = tcp
|
- |
|
42 |
|
26 |
|
43 |
# Option: chain
|
27 |
# Option: chain
|
44 |
# Notes specifies the iptables chain to which the fail2ban rules should be
|
28 |
# Notes specifies the iptables chain to which the fail2ban rules should be
|
45 |
# added
|
29 |
# added
|
46 |
# Values: [ STRING ]
|
30 |
# Values: [ STRING ]
|
Line 57... |
Line 41... |
57 |
#
|
41 |
#
|
58 |
# $ firewall-cmd --direct --add-chain ipv4 filter fail2ban-name
|
42 |
# $ firewall-cmd --direct --add-chain ipv4 filter fail2ban-name
|
59 |
# success
|
43 |
# success
|
60 |
# $ firewall-cmd --direct --add-rule ipv4 filter fail2ban-name 1000 -j RETURN
|
44 |
# $ firewall-cmd --direct --add-rule ipv4 filter fail2ban-name 1000 -j RETURN
|
61 |
# success
|
45 |
# success
|
62 |
# $ sudo firewall-cmd --direct --add-rule ipv4 filter INPUT_direct 0 -m state --state NEW -p tcp --dport 22 -j fail2ban-name
|
46 |
# $ sudo firewall-cmd --direct --add-rule ipv4 filter INPUT_direct 0 -m state --state NEW -p tcp -m multiport --dports 22 -j fail2ban-name
|
63 |
# success
|
47 |
# success
|
64 |
# $ firewall-cmd --direct --get-chains ipv4 filter
|
48 |
# $ firewall-cmd --direct --get-chains ipv4 filter
|
65 |
# fail2ban-name
|
49 |
# fail2ban-name
|
66 |
# $ firewall-cmd --direct --get-chains ipv4 filter | od -h
|
50 |
# $ firewall-cmd --direct --get-chains ipv4 filter | od -h
|
67 |
# 0000000 6166 6c69 6232 6e61 6e2d 6d61 0a65
|
51 |
# 0000000 6166 6c69 6232 6e61 6e2d 6d61 0a65
|