unban ip in fail2ban

How to Unban IP With Fail2ban

Fail2ban is a popular firewall and security tool that protects your server from malicious attacks. It automatically detects questionable behavior from IP addresses sending requests to your server and blocks them using jail-rules. But sometimes you may find that it has blocked a friendly IP address, and you may want to unban it from your system. In this article, we will learn how to unban IP with Fail2ban.

How to Unban IP With Fail2ban

Here are the steps to unban IP with Fail2ban.

1. Find the right jail

Fail2ban organizes the banned IP addresses into various jails. The tricky part is to find the right jail for the banned IP address. Open terminal and run the following command to list all iptables rules.

$ iptables -L -n

Run the following command to get actual jail names.

$ fail2ban-client status | grep "Jail list" | sed -E 's/^[^:]+:[ \t]+//' | sed 's/,//g'

Analyze the iptables rules and fail2ban jail names to identify the right combination of iptables rule and fail2ban jail name.

2. Unban IP address

Once you have figured out the right jail name, run the following command to unban that IP address from the jail. Replace JAILNAMEHERE with jail name of banned IP and IPADDRESSHERE with the IP address you want to unban.

Fail2ban < v0.8.8

$ fail2ban-client get JAILNAMEHERE actionunban IPADDRESSHERE

Fail2ban > v0.8.8

$ fail2ban-client set JAILNAMEHERE unbanip IPADDRESSHERE

That’s it. In this short article, we have learnt how unban IP address with Fail2ban.

Also read:

NGINX Allow Local Network
How to Prevent Direct Access to Images in NGINX
How to Prevent Direct Access to Images in Apache
How to Know Which Shell I am Using in Linux
How to Delete Objects in Django

Leave a Reply

Your email address will not be published. Required fields are marked *