1
0
mirror of synced 2024-11-21 20:46:10 +03:00

CentOS/RHEL 8 fix

- Fix fail2ban rules for nftables on CentOS/RHEL 8
This commit is contained in:
hwdsl2 2020-07-02 17:52:13 -05:00
parent 012c19fed1
commit 8283bdb32f

View File

@ -381,15 +381,26 @@ net.ipv4.tcp_wmem = 10240 87380 12582912
EOF
fi
if [ ! -f /etc/fail2ban/jail.local ] ; then
F2B_FILE="/etc/fail2ban/jail.local"
if [ ! -f "$F2B_FILE" ]; then
bigecho "Creating basic Fail2Ban rules..."
cat > /etc/fail2ban/jail.local <<'EOF'
cat > "$F2B_FILE" <<'EOF'
[ssh-iptables]
enabled = true
filter = sshd
action = iptables[name=SSH, port=ssh, protocol=tcp]
logpath = /var/log/secure
enabled = true
filter = sshd
logpath = /var/log/secure
EOF
if [ "$use_nft" = "1" ]; then
cat >> "$F2B_FILE" <<'EOF'
port = ssh
banaction = nftables-multiport[blocktype=drop]
EOF
else
cat >> "$F2B_FILE" <<'EOF'
action = iptables[name=SSH, port=ssh, protocol=tcp]
EOF
fi
fi
bigecho "Updating IPTables rules..."