Home / Configs / Servers / fail2ban jail.local

fail2ban jail.local example: ban repeated login failures

Ban addresses that keep failing to log in. Choose ban time, retries and which services to protect.

For Linux servers with fail2ban 0.10 or newer (Debian, Ubuntu, Fedora). Check the version with fail2ban-client --version.

fail2ban watches your logs and blocks addresses that fail to log in too many times. Put your settings in jail.local so package updates never overwrite them. Add your own address to the ignore list first, so you cannot lock yourself out.

Create your config file

Type your own values. The file below updates as you type, and nothing you type leaves your browser.

Examples: 10m, 1h, 1d
The window the failures are counted in
Add your own IP, separated by spaces
ssh, or a number like 2222

/etc/fail2ban/jail.local
[DEFAULT]
bantime  = 1h
findtime = 10m
maxretry = 5
ignoreip = 127.0.0.1/8 ::1

[sshd]
enabled = true
port    = ssh
backend = auto

How this setup works

Diagram: Failed logins, then fail2ban, then Firewall
Failed logins (written to a log) → fail2ban (counts them) → Firewall (blocks the address)

Step-by-step setup

  1. Install it: sudo apt install fail2ban (Debian, Ubuntu).
  2. Save the config as /etc/fail2ban/jail.local.
  3. Start it: sudo systemctl enable --now fail2ban, or sudo systemctl restart fail2ban after a change.
  4. See the jails: sudo fail2ban-client status.
  5. See banned addresses: sudo fail2ban-client status sshd.

What the important lines mean

Common errors and how to fix them

You locked yourself out
Wait for the ban to end, or from the console run sudo fail2ban-client set sshd unbanip YOUR.IP. Then add your address to ignoreip.
Have not found any log file for sshd jail
The log file does not exist. Choose the systemd journal as the SSH log source.
Failed to access socket path
Fail2ban is not running. Check systemctl status fail2ban and its log.
Bans do not block anything
Check that the firewall that fail2ban uses (iptables or nftables) is installed and active.

Frequently asked questions

Where does fail2ban store its settings?
Defaults are in /etc/fail2ban/jail.conf. Your own settings go in /etc/fail2ban/jail.local.
How do I unban an IP address?
Run sudo fail2ban-client set sshd unbanip with the address.
Does it protect against all attacks?
No. It slows password guessing. Use SSH keys and keep software updated as well.

Written for: fail2ban 1.0, Ubuntu 24.04 · Updated 2026-10-03

Free tools that help

More server configs

See all 41 config generators