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
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop












{ 3 comments… read them below or add one }
I think your command to determine if an IP address exists in the INPUT chain might need to be refined. For example the following would be detected 401 20304 if you grepped for “1.2.3.4″.
This is true. In order to get the literal character of “.” You would need to escape them, using “\” as the escape character. So something like this:
Iptables -L INPUT -v -n | grep “1\.2\.3\.4″
You can also use single quotes instead of doubles: