[Tech] How to unban an IP address from your server using fail2ban?
While this blog usually aims at explaining hosting topics to the non-specialist, we occasionally post some more technical stuff to help our fellow sysadmins with a specific issue. these posts are titled with a [Tech] flag, so feel free to skip them if you don’t want the gory details!
So, it may happen that you’re using fail2ban to protect your server, Cloud or Dedicated.
Fail2ban is a nifty little software that will parse the logs of your chosen services (httpd, ftpd, sshd…) and, according to rules you set, will ban an IP address that matches your rules. A common usage is to ban an IP address after, say, 5 failed attempts to identify on ssh.
But sometimes you make some tests and… end up with your own IP banned. Yeah, it happens to the best of us! The problem is, a quick google search will leave you frustrated as the standard suggested solution doesn’t actually work.
If you tried something like:
fail2ban-client get [JAIL] actionunban [xx.xx.xx.xx]
Well, it won’t work and you’ll only get an ‘Invalid Action name’ error for your efforts.
The real solution is to use:
fail2ban-client set [JAIL] unbanip [xx.xx.xx.xx]
And voila! Your IP is no longer banned, and proper entries are logged.