Fail2Ban
What does this mean in plain English?
The moment you connect a Linux server to the internet, automated malicious botnets from around the world begin attacking it. They attempt thousands of random passwords per minute against your SSH login port, try default administrator passwords on your database, and hammer your WordPress or PrestaShop login forms.
Fail2Ban is your server automated security guard. It quietly monitors log files in real time. If an IP address attempts to guess a password three times and fails, Fail2Ban immediately instructs the Linux firewall to slam the door shut, blocking that IP address from connecting for hours or days. It stops brute-force attacks in their tracks without slowing down legitimate users.
How does it work under the hood?
Fail2Ban operates as a Python daemon coordinating multiple log filters and firewall actions.
1. Log Analysis Filters: Filters contain optimized regular expressions (`failregex`) tailored for specific services (SSH, Nginx HTTP authentication, Postfix mail, Proxmox GUI, WordPress). The daemon parses log streams (or systemd journal logs) as new lines are appended.
2. Penalty Thresholds: If an IP triggers a configured number of failures (`maxretry`, typically 3 to 5) within a specific evaluation window (`findtime`, typically 600 seconds), Fail2Ban flags the IP as hostile.
3. Firewall Rule Insertion: Fail2Ban calls system commands to insert a temporary drop or reject rule into the host firewall subsystem (such as an `nftables` set or an `iptables` chain). The attacker packets are dropped silently at the kernel level with zero CPU overhead.
Why does this matter & key engineering advantages?
Without intrusion prevention, automated brute-force attacks consume CPU cycles, flood server logs with millions of junk entries, and dramatically increase the risk of credential compromise. Fail2Ban neutralizes automated scanners instantly, keeping authentication services calm, secure, and responsive.
Yamiru's production experience & real-world use
Fail2Ban is standard equipment across all Yamiru server deployments. Hardened custom jail configurations protect SSH, Nginx rate-limit violations, and WordPress/PrestaShop administrative endpoints on all production virtual machines.
Frequently Asked Questions
It can if an administrator repeatedly enters an incorrect password. To prevent this, trusted administrative IP ranges, office VPNs, and localhost are explicitly whitelisted in the `ignoreip` configuration directive.
Modern Fail2Ban supports native `nftables` actions, using high-performance set lookups that process millions of blocked IPs with zero packet latency penalty.
Fail2Ban persists active bans in a local SQLite database (`/var/lib/fail2ban/fail2ban.sqlite3`), so active bans are re-applied immediately after server reboots.