5 |
- |
1 |
# Fail2Ban action file for firewall-cmd/ipset
|
|
|
2 |
#
|
|
|
3 |
# This requires:
|
|
|
4 |
# ipset (package: ipset)
|
|
|
5 |
# firewall-cmd (package: firewalld)
|
|
|
6 |
#
|
|
|
7 |
# This is for ipset protocol 6 (and hopefully later) (ipset v6.14).
|
|
|
8 |
# Use ipset -V to see the protocol and version.
|
|
|
9 |
#
|
|
|
10 |
# IPset was a feature introduced in the linux kernel 2.6.39 and 3.0.0 kernels.
|
|
|
11 |
#
|
|
|
12 |
# If you are running on an older kernel you make need to patch in external
|
|
|
13 |
# modules.
|
|
|
14 |
|
|
|
15 |
[INCLUDES]
|
|
|
16 |
|
|
|
17 |
before = iptables-blocktype.conf
|
|
|
18 |
|
|
|
19 |
[Definition]
|
|
|
20 |
|
|
|
21 |
actionstart = ipset create fail2ban-<name> hash:ip timeout <bantime>
|
|
|
22 |
firewall-cmd --direct --add-rule ipv4 filter <chain> 0 -p <protocol> -m multiport --dports <port> -m set --match-set fail2ban-<name> src -j <blocktype>
|
|
|
23 |
|
|
|
24 |
actionstop = firewall-cmd --direct --remove-rule ipv4 filter <chain> 0 -p <protocol> -m multiport --dports <port> -m set --match-set fail2ban-<name> src -j <blocktype>
|
|
|
25 |
ipset flush fail2ban-<name>
|
|
|
26 |
ipset destroy fail2ban-<name>
|
|
|
27 |
|
|
|
28 |
actionban = ipset add fail2ban-<name> <ip> timeout <bantime> -exist
|
|
|
29 |
|
|
|
30 |
actionunban = ipset del fail2ban-<name> <ip> -exist
|
|
|
31 |
|
|
|
32 |
[Init]
|
|
|
33 |
|
|
|
34 |
# Default name of the chain
|
|
|
35 |
#
|
|
|
36 |
name = default
|
|
|
37 |
|
|
|
38 |
# Option: port
|
|
|
39 |
# Notes.: specifies port to monitor
|
|
|
40 |
# Values: [ NUM | STRING ]
|
|
|
41 |
#
|
|
|
42 |
port = ssh
|
|
|
43 |
|
|
|
44 |
# Option: protocol
|
|
|
45 |
# Notes.: internally used by config reader for interpolations.
|
|
|
46 |
# Values: [ tcp | udp | icmp | all ]
|
|
|
47 |
#
|
|
|
48 |
protocol = tcp
|
|
|
49 |
|
|
|
50 |
# Option: chain
|
|
|
51 |
# Notes specifies the iptables chain to which the fail2ban rules should be
|
|
|
52 |
# added
|
|
|
53 |
# Values: [ STRING ]
|
|
|
54 |
#
|
|
|
55 |
chain = INPUT_direct
|
|
|
56 |
|
|
|
57 |
# Option: bantime
|
|
|
58 |
# Notes: specifies the bantime in seconds (handled internally rather than by fail2ban)
|
|
|
59 |
# Values: [ NUM ] Default: 600
|
|
|
60 |
|
|
|
61 |
bantime = 600
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
# DEV NOTES:
|
|
|
65 |
#
|
|
|
66 |
# Author: Edgar Hoch and Daniel Black
|
|
|
67 |
# firewallcmd-new / iptables-ipset-proto6 combined for maximium goodness
|