Linux: Iptables Find / Check Banned IP Address

How do I find or check IP’s that are currently banned using iptables command in Linux? How do I verify that IP address 1.2.3.4 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 1.2.3.4 as follows:
# /sbin/iptables -A INPUT -s 65.55.44.100 -j DROP
To view blocked IP address, enter:
# iptables -L INPUT -v -n
OR
# iptables -L INPUT -v -n | less

Task: Check Banned IP’s Linux

Use the grep command as follows to verify that an IP address 1.2.3.4 is blocked or not:
# iptables -L INPUT -v -n | grep "1.2.3.4"

How Do I Delete or Unblock IP Address 1.2.3.4?

Use the following syntax to delete or unblock an IP address under Linux, enter:
# iptables -D INPUT -s 1.2.3.4 -j DROP
Finally, make sure you save the firewall:
# service iptables save

  • server, centos, linux-server
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Change HostName in CentOS 7 / RHEL 7

Method 1 : nmcli To view the current hostname : # nmcli general hostname...

How to delete terminal history in Linux

You can clear your bash history like this: cat /dev/null > ~/.bash_history && history...

How to change SSH Port in Linux

# vi /etc/ssh/sshd_configYou have to change port 22 to whatever you want#Port 22 #ta delete kore...

How to install wget on CentOS 7/8

The procedure to install wget command is as follows on CentOS Linux 7/8: Open a terminal...

How to install Webuzo on CentOS 7

Requirements Newly installed CentOS 6.x / 7.x or Red Hat Enterprise Linux 6.x / 7.x or...