Bonjour
Je suis sous yunohost v11.2.9.1, et je reçois depuis un certain temps beaucoup de tentatives de connexions sur mon serveur.
J’ai activé fail2ban, j’ai fini par comprendre comment ça marchait, et en suivant quelques tutos sur le net, j’ai configuré le service de façon à ce qu’il bannisse les IP de plus en plus longtemps à mesure qu’elle enchaine les échecs d’authentification.
Voici le contenu des fichiers que j’ai modifié ou créé pour ça :
/etc/fail2ban/jail.d/recidive.conf
[recidive1]
enabled = true
filter = recidive
bantime = 10800 ; 3 hours
findtime = 86400 ; 1 day
logpath = /var/log/fail2ban.log
maxretry = 1
[recidive2]
enabled = true
filter = recidive
bantime = 86400 ;1 day
findtime = 604800 ;1 week
logpath = /var/log/fail2ban.log
maxretry = 2
[recidive3]
enabled = true
filter = recidive
bantime = 604800 ;1 week
findtime = 2592000 ;1 month
logpath = /var/log/fail2ban.log
maxretry = 3
[recidive4]
enabled = true
filter =recidive
bantime = 2592000 ;1 month
findtime = 15552000 ;6 months
logpath = /var/log/fail2ban.log
maxretry = 4
[recidive5]
enabled = true
filter =recidive
bantime = 15552000 ;6 month
findtime = 31104000 ;12 months
logpath = /var/log/fail2ban.log
maxretry = 5
et /etc/fail2ban/filter.d/recidive.conf
# Fail2Ban filter for repeat bans
#
# This filter monitors the fail2ban log file, and enables you to add long
# time bans for ip addresses that get banned by fail2ban multiple times.
#
# Reasons to use this: block very persistent attackers for a longer time,
# stop receiving email notifications about the same attacker over and
# over again.
#
# This jail is only useful if you set the 'findtime' and 'bantime' parameters
# in jail.conf to a higher value than the other jails. Also, this jail has its
# drawbacks, namely in that it works only with iptables, or if you use a
# different blocking mechanism for this jail versus others (e.g. hostsdeny
# for most jails, and shorewall for this one).
[INCLUDES]
# Read common prefixes. If any customizations available -- read them from
# common.local
before = common.conf
[Definition]
_daemon = (?:fail2ban(?:-server|\.actions)\s*)
# The name of the jail that this filter is used for. In jail.conf, name the jail using
# this filter 'recidive', or supply another name with `filter = recidive[_jailname="jail"]`
_jailname = recidive
failregex = ^%(__prefix_line)s(?:\s*fail2ban\.actions\s*%(__pid_re)s?:\s+)?NOTICE\s+\[(?!%(_jailname)s\])(?:.*)\]\s+Ban\s+<HOST>\s*$
datepattern = ^{DATE}
ignoreregex = \[recidive.*\]\s+Ban\s+<HOST>
journalmatch = _SYSTEMD_UNIT=fail2ban.service PRIORITY=5
# Author: Tom Hendrikx, modifications by Amir Caspi
Tout fonctionne à peu près correctement, mais ma dernière jail (“recidive5”) ne se remplit jamais, malgré les détections que me confirme la commande
fail2ban-client status recidive5
Quelqu’un aurait une explication à ça ? Ou mieux, une solution ? C’est vraiment étrange, d’autant que les autres jails (de recidive1 à recidive4 fonctionnent très bien).
Merci d’avance à tous pour vos réponses !