Будут только правила для некоторого софта и команды-незабудки.
tail -f /var/log/fail2ban.log
fail2ban-client status
fail2ban-client status nazvanie_pravila
fail2ban-client banned
fail2ban-client set nazvanie_pravila unbanip ip.ip.ip.ip
/etc/fail2ban/filter.d/nextcloud.conf
[Definition]
_groupsre = (?:(?:,?\s*"\w+":(?:"[^"]+"|\w+))*)
failregex = ^\{%(_groupsre)s,?\s*"remoteAddr":"<HOST>"%(_groupsre)s,?\s*"message":"Login failed:
^\{%(_groupsre)s,?\s*"remoteAddr":"<HOST>"%(_groupsre)s,?\s*"message":"Trusted domain error.
datepattern = ,?\s*"time"\s*:\s*"%%Y-%%m-%%d[T ]%%H:%%M:%%S(%%z)?"
/etc/fail2ban/jail.d/nextcloud.conf
[nextcloud]
enabled = true
filter = nextcloud
action = route
logpath = /var/log/nextcloud.log
findtime = 36000
maxretry = 3
bantime = 2592000
ignoreip = 192.168.250.0/24
Так же нужно установить для Nextcloud уровень логирования, расположение лог-файла и формат даты:
cd /var/www/nextcloud
sudo -u www-data php occ log:file --file /var/log/nextcloud.log --rotate-size 100M --enable
sudo -u www-data php occ log:manage --level 2 --timezone Europe/Moscow
/etc/fail2ban/filter.d/postfix-sasl.conf
[INCLUDES]
before = common.conf
[Definition]
_daemon = postfix(-\w+)?/\w+(?:/smtp[ds])?
failregex = ^%(__prefix_line)swarning: [-._\w]+\[<HOST>\]: SASL LOGIN authentication failed
ignoreregex =
/etc/fail2ban/jail.d/postfix-sasl.conf
[postfix-sasl]
enabled = true
filter = postfix-sasl
action = route
logpath = /var/log/mail.log
maxretry = 3
findtime = 900
ignoreip = 192.168.99.0/24