🚫
Security

Fail2ban

Block brute-force attacks by banning IPs

🐧 Linux🍎 Mac🪟 Windows
Reviewed: Tested on: Kubernetes 1.29 · Terraform 1.8 · Ubuntu 22.04

What is this?

Fail2ban automatically blocks IP addresses that try to brute-force your server.

📁

Config files for Fail2ban

Where to create or edit the main configuration — paths below match the setup steps.

  • /etc/fail2ban/jail.local

    Location: Fail2ban server

    Jail rules and ban settings (override jail.conf)

📥

Step 01

Install Fail2ban

(01)Install Fail2ban

Linux
1sudo apt-get install -y fail2ban
2sudo systemctl enable fail2ban && sudo systemctl start fail2ban
⚙️

Step 02

Configure Fail2ban

(01)Configure Fail2ban

Linux
1sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
2sudo systemctl restart fail2ban

Step 03

Verify

(01)Verify installation

Linux
1sudo fail2ban-client status
2sudo fail2ban-client status sshd