fail2ban🔗
Installation🔗
Setup🔗
- Create a local configuration :
jail.local
- Edit Configuration file
/etc/fail2ban/jail.local
- Enable Jails
Commands🔗
-
Check Status
-
Unban an IP
-
Ban an IP Manually
-
Reload Configuration
Advanced Use-Cases🔗
-
Create a custom filter in
/etc/fail2ban/filter.d/
-
Email Notifications: Configure mail alerts in
jail.local
[DEFAULT] destemail = [email protected] sender = [email protected] action = %(action_mwl)s
Example Configurations🔗
Securing MailCow Mailserver🔗
Create a new filter : /etc/fail2ban/filter.d/mailcow.conf
[Definition]
failregex = LOGIN authenticator failed for .+ \[<HOST>\]:.*
NOQUEUE: reject: RCPT from \[<HOST>\].* Auth failure: 535
Add [mailcow]
jail in /etc/fail2ban/jail.conf
[mailcow]
enabled = true
port = smtp, submission, imap, imaps, pop3, pop3s
filter = mailcow
logpath = /opt/mailcow-dockerized/mailcow.conf
maxretry = 3
bantime = 3600
Securing Nextcloud with Fail2Ban🔗
Create a new filter : /etc/fail2ban/filter.d/nextcloud.conf
Add [nextcloud]
jail in /etc/fail2ban/jail.conf
[nextcloud]
enabled = true
port = http, https
filter = nextcloud
logpath = /path/to/nextcloud.log
maxretry = 3
bantime = 3600