Wednesday 6 January 2021

How to remove banned IP from iptables ?

After my IP banned by fail2ban, I could not unban it using any fail2ban-client commands but this one works.

Suppose the banned IP is 1.2.3.4.  So execute:

iptables -S | grep 1.2.3.4

 If the IP is really banned you should see a line like:


-A f2b-sshd -s 1.2.3.4/32 -j REJECT --reject-with icmp-port-unreachable


To remove the line just replace -A with -D, like this:


 iptables -D  f2b-sshd -s 1.2.3.4/32 -j REJECT --reject-with icmp-port-unreachable


This should remove the line. Test  `iptables -S | grep 1.2.3.4` and there should be not more output. 


Note: sometimes an IP may be in fail2ban banlist. In that cas you can I ban it using:


fail2ban-client set sshd  unbanip 1.2.3.4







No comments:

Post a Comment