Prerequisites
- A Linux server with Fail2Ban installed
- A service that logs its authentication failures (SSH, Nginx…)
01Never edit jail.conf
The .conf files shipped with the package can be overwritten on every update. Your settings go in jail.local (or a .local file in jail.d): they override jail.conf, section by section.
02A minimal jail.local
ignoreip avoids banning yourself from the local network. bantime.increment lengthens bans for repeat offenders. banaction picks the firewall that applies the bans, here nftables.
On Debian 12 and later, SSH writes to the systemd journal and no longer to /var/log/auth.log: without backend = systemd (and the python3-systemd package), the sshd jail finds no file and Fail2Ban refuses to start.
[DEFAULT]
bantime = 1h
findtime = 10m
maxretry = 5
bantime.increment = true
ignoreip = 127.0.0.1/8 ::1 192.168.10.0/24
banaction = nftables-multiport
[sshd]
enabled = true
backend = systemd03Apply and monitor
fail2ban-client reload
fail2ban-client status sshd # current bans
fail2ban-client set sshd unbanip 203.0.113.7 # lift a ban
fail2ban-client -d # effective configuration04What Fail2Ban doesn’t do
It slows down dictionary attacks; it doesn’t replace strong authentication. With key-only SSH, attempts fail anyway: Fail2Ban then mostly reduces noise in the logs.
Key takeaways
- Settings in jail.local, never in jail.conf.
- bantime, findtime, maxretry: the policy in three values.
- Debian 12+: backend = systemd for SSH.
- ignoreip so you don’t lock yourself out.
Example addresses.