I'm using Fail2Ban on a server and I'm wondering how to unban an IP properly.
I know I can work with IPTables directly: iptables -D fail2ban-ssh <number>
But is there not a way to do it with the fail2ban-client
?
In the manuals it states something like: fail2ban-client get ssh actionunban <IP>
. But that doesn't work.
Also, I don't want to /etc/init.d/fail2ban restart
as that would lose all the bans in the list.
With Fail2Ban before v0.8.8:
With Fail2Ban v0.8.8 and later:
The hard part is finding the right jail:
iptables -L -n
to find the rule name...fail2ban-client status | grep "Jail list" | sed -E 's/^[^:]+:[ \t]+//' | sed 's/,//g'
to get the actual jail names. The rule name and jail name may not be the same but it should be clear which one is related to which.Since v0.8.8 there is the
unbanip
option (actionunban
isn't for this purpose) It can be triggered by theset
command, if you look at the list of options, you will see the syntax is. So it will be (by heart, please check):more generic:
works for me
Example for SSH in interactive mode.
type in bash:
then in interactive mode type read the status of a jail:
you'll get:
then type in fail2ban interactive mode:
you'll get:
it means no longer
203.113.167.162
in ban list.The answer of ukoda is wrong:
Call
fail2ban-client
without parameters and you see a list of possible commands:This gets the unban command for the action ACT for JAIL.
Look into the action parameter of the jail you defined, you probably have an iptables action and maybe some more like sendmail, whois or whatever. so in case your action was iptables it will look like this:
and the answer will be:
It will only show you what you would have to write for an unban. There is no unban command itself.
If 192.168.2.1 is banned
Check which Chain it's banned in e.g.
Then:
If you are running version v0.10.2:
This is from help:
Confirmed to work in my case when I most likely got banned due to ssh client logging in repeatedly with wrong password.
You first need to get the name of the jail. You can get the list (in most cases it will be only ssh jail):
After getting the jail name you can check which IPs are being ignored.
If your IP is in ignore list, you can delete it via:
Remove your host entry:
Using fail2ban v.0.8.6:
unfortunately with version 0.8.2 of fail2ban-client the command:
does not run. To solve the problem, best choice is upgrade fail2ban to latest version and use new option:
would work.