How do I find or check IP’s that are currently banned using iptables command in Linux? How do I verify that IP address 188.8.131.52 is banned or not in Linux?
The correct syntax to block an IP address under Linux using iptables is as follows:
/sbin/iptables -A INPUT -s BAN-IP-ADDRESS -j DROP /sbin/iptables -A INPUT -s BAN-IP-ADDRESS/MASK -j DROP
Open a command-line terminal (select Applications > Accessories > Terminal), or login to remote server using the ssh and then type the following command block an ip address 184.108.40.206 as follows:
# /sbin/iptables -A INPUT -s 220.127.116.11 -j DROP
To view blocked IP address, enter:
# iptables -L INPUT -v -n
# iptables -L INPUT -v -n | less
Task: Check Banned IP’s Linux
Use the grep command as follows to verify that an IP address 18.104.22.168 is blocked or not:
# iptables -L INPUT -v -n | grep "22.214.171.124"
How Do I Delete or Unblock IP Address 126.96.36.199?
Use the following syntax to delete or unblock an IP address under Linux, enter:
# iptables -D INPUT -s 188.8.131.52 -j DROP
Finally, make sure you save the firewall:
# service iptables save