← Tutte le guide
Fail2ban
Fail2ban watches service log files for repeated authentication failures and automatically bans offending IPs via firewall rules, using per-service 'jails' you enable in jail.local.
Questa guida è redatta a partire dalla documentazione ufficiale di Fail2ban, linkata sopra — verifica sempre lì i nomi esatti di pacchetti/versioni prima di eseguire questi comandi su un server di produzione, poiché le versioni della distribuzione e del progetto cambiano nel tempo.
1Install the package
Fail2ban is already packaged for Debian/Ubuntu, which is the officially recommended way to install it rather than building from source.
sudo apt updatesudo apt install fail2ban2Create a local jail configuration
jail.conf is overwritten on updates — a jail.local override is the documented way to keep customizations safe.
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.localEdit jail.local to enable jails (e.g. [sshd]) and adjust bantime/findtime/maxretry.
3Enable and start the service
sudo systemctl enable --now fail2bansudo fail2ban-client status