brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ignoreip in jail.local stops fail2ban from banning your own network

Linux
~/tips/tip-security-fail2ban-ignoreip-jail-local

ignoreip = 127.0.0.1/8 ::1 192.168.1.0/24 100.64.0.0/10

Keeps fail2ban from banning addresses on your own LAN or tailnet.

Fail2ban is great until it bans you. Type your password wrong a few times from the couch, or let a misconfigured script hammer a login, and your own laptop ends up on the block list. I’d tell fail2ban up front which addresses are mine.

Put it in /etc/fail2ban/jail.local, never in jail.conf. The man page says the .conf files belong to the package and should stay unchanged, and that .local files are read after them and win:

[DEFAULT]
ignoreip = 127.0.0.1/8 ::1 192.168.1.0/24 100.64.0.0/10
sudo fail2ban-client reload
sudo fail2ban-client get sshd ignoreip

ignoreip takes single addresses, CIDR ranges and DNS names, separated by spaces or commas. In the example 192.168.1.0/24 is the home LAN and 100.64.0.0/10 is the range Tailscale hands out, which makes sense if, like me, you reach your machines over Tailscale. ignoreself is on by default, so the server’s own addresses are already skipped. The second command asks a running jail which addresses it ignores, a nice way to check that your change landed.

Two caveats. If you also set ignoreip inside a jail section such as [sshd], that line replaces the one from [DEFAULT] for that jail, so repeat your ranges there. And every address on this list can guess passwords forever. A whole LAN is fine for a home server, but I wouldn’t add a big public range or a shared office network just to save myself a ban.

Further reading: jail.conf manual page, fail2ban default jail.conf on GitHub

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link