Configure fail2ban to use route instead of iptables to block connections

Fail2ban uses iptables by default to block incoming connections when they exceed the max.  login retries. The iptables rules used by fail2ban might conflict with other firewall rules, so it might be necessary to reconfigure fail2ban to use the route command for blocking incoming connections.

Fail2ban ban using route command

To reconfigure fail2ban for using the route command instead of iptables, edit or create the route.conf file:

nano /etc/fail2ban/action.d/route.conf

There you insert the following lines:

# Fail2Ban configuration file

[Definition]
actionban = ip route add unreachable 
actionunban = ip route del unreachable 

Then add or change the ban action in the jail.local file in the [DEFAULT] section to “route”:

Sponsored
nano

Sponsored
/etc/fail2ban/jail.local

And add or edit these lines:

# Fail2Ban configuration file

[DEFAULT]

banaction = route

The post Configure fail2ban to use route instead of iptables to block connections appeared first on FAQforge.

Ubuntu Server Admin

Recent Posts

Canonical and NVIDIA BlueField-4: a foundation for zero-trust high performance infrastructure

At NVIDIA GTC Washington D.C., Canonical is pleased to support the arrival of the NVIDIA…

22 hours ago

Global-ready from day one

How Anbox Cloud streamlines localization testing Wherever users are based, they expect apps to just…

3 days ago

Canonical announces new optimized Ubuntu image for Thundercomm RUBIK Pi 3

Ubuntu now runs natively on the Thundercomm RUBIK Pi 3 developer board – a lightweight…

6 days ago

Introducing Canonical Academy

Validate your skills and advance your career with recognized qualifications from the publishers of Ubuntu…

6 days ago

🚀 Deploy Poweradmin to Manage PowerDNS on Ubuntu VPS

This article demonstrates how to deploy Poweradmin to manage PowerDNS on Ubuntu VPS server. What…

6 days ago

Self-Hosting Easypanel and n8n on Ubuntu VPS

This article provides an outline for self-hosting Easypanel and n8n on Ubuntu VPS. What is…

6 days ago