Documentation / Tutorials / Server
Remove ban from IPs banned by Fail2Ban
/ Server / Remove ban from IPs banned by Fail2Ban
Assuming you have secured your server using fail2ban, there comes a time when you may ban an IP wrongly. Here is how you can quickly check if that IP is banned and then un-ban it.
fail2ban-client status | sed -n 's/,//g;s/.*Jail list://p' | xargs -n1 fail2ban-client status
this command will give you a list of all the IPs banned by fail2ban and the Jail under which it has been banned. if you the name of the jail you can check it using the following command as well.
sudo fail2ban-client status wordpress2
where wordpress2 is the name of the jail, as defined in jail.conf file.
fail2ban-client set wordpress2 unbanip 184.108.40.206
Once you have verified the IP, if it is banned you can use above command to remove the ban, wordpress2 is the name of the jail, while IP 220.127.116.11 is the IP which is being removed from ban.
If you have static IPs then you can whitelist them so that they do not get banned, it can be done by setting ignoreip in jail.conf or jail.local file. Here is an example of it
ignoreip = = 127.0.0.1/8 18.104.22.168/21 22.214.171.124/19 126.96.36.199/24 188.8.131.52/24 184.108.40.206/24 220.127.116.11/24 18.104.22.168/24 22.214.171.124/24 126.96.36.199/24 188.8.131.52/24 184.108.40.206/24 220.127.116.11/24 18.104.22.168/24 22.214.171.124/24 126.96.36.199/20 188.8.131.52/21 184.108.40.206/16 220.127.116.11/21 18.104.22.168/16 22.214.171.124/24 126.96.36.199/21 188.8.131.52/24 184.108.40.206/21 220.127.116.11/19 18.104.22.168/20 22.214.171.124/16 126.96.36.199/16 188.8.131.52/24 184.108.40.206/20 220.127.116.11/16 18.104.22.168/24 22.214.171.124/22 126.96.36.199/19 188.8.131.52/24 184.108.40.206/19 220.127.116.11/22 18.104.22.168/19 22.214.171.124
You can see how a range of IPs or multiple IPs can be added. Afterwards, remember to restart the fail2ban server using
service fail2ban restart