Fail2Ban
Setup
Configure
Make a copy of jail.conf as jail.local and edit it to configure. Do not edit jail.conf as it will get overwritten when fail2ban updates.
After updating jail.local file restart fail2ban and check the status.
Monitor Realtime Activity
SSHD Specific Fail2Ban Actions
Strong Setup for SSHD
Create or edit /etc/fail2ban/jail.local:
The settings below will ban an IP permanently after 3 failed ssh login attempts within a 10-minute window.
[sshd]
# To use more aggressive sshd modes set filter parameter "mode" in jail.local:
# normal (default), ddos, extra or aggressive (combines all).
# See "tests/files/logs/sshd" or "filter.d/sshd.conf" for usage example and details.
mode = aggressive
port = ssh
logpath = %(sshd_log)s
backend = %(sshd_backend)s
findtime = 600
maxretry = 3
bantime = -1
Strong Setup for NGINX
The settings below will ban an IP for a week after 5 failed tries within a 10-minute window.
[nginx-limit-req]
enabled = true
port = http,https
logpath = %(nginx_error_log)s
findtime = 600
maxretry = 5
bantime = 604800
[nginx-botsearch]
enabled = true
port = http,https
logpath = %(nginx_access_log)s
findtime = 600
maxretry = 5
bantime = 604800
[nginx-bad-request]
enabled = true
port = http,https
logpath = %(nginx_access_log)s
findtime = 600
maxretry = 5
bantime = 604800