How to configure Fail2Ban with UFW
Configure Fail2Ban to use UFW as the ban action backend instead of iptables on Ubuntu and Debian systems.
How to configure Fail2Ban with UFW
Configure Fail2Ban to use UFW as the ban action backend instead of iptables on Ubuntu and Debian systems.
Prerequisites
- Fail2Ban and UFW installed on Ubuntu or Debian.
- UFW enabled and active.
Step-by-Step: Configure Fail2Ban to Use UFW
Edit
/etc/fail2ban/jail.localand set the ban action toufwin the[DEFAULT]section:[DEFAULT] banaction = ufw banaction_allports = ufwRestart Fail2Ban to apply the new backend:
sudo systemctl restart fail2ban
How to Verify Fail2Ban Uses UFW
When Fail2Ban bans an IP, UFW shows the ban rule in its rule list:
sudo ufw statusCheck the Fail2Ban log for UFW action messages:
sudo tail -20 /var/log/fail2ban.log