How can I block a IP address?

To block an individual IP address from accessing your Linux server, you can use the following iptables command:

iptables -A INPUT -s IPADDR -j DROP


Simply replace IPADDR with the IP you want to drop all packets from.


Block ranges of IP's


Here is an example of a range block:

iptables -A INPUT -s 192.168.0.1/24 -j DROP


This would block 192.168.0.1-255


Unblock the IP


Simply change "DROP" in the commands above to "ACCEPT".

  • 84 Users Found This Useful
Was this answer helpful?

Related Articles

How can I reset my root password?

This article explains how to reset your server root password if you no longer know it. You will...

How to use iptables?

Warning Modifying rules on your server can cause the server to become inaccessible on port 22...

How to install rkhunter ?

Rootkit Hunter Rootkit scanner is scanning tool to ensure you for about 99.9%* you're clean of...

How to install syslog server ?

Syslog Features : 1. Logs the daemon information to Remote host2. Logs the daemon information to...

How to get email alert for SSH root login ?

Get Email alert on ssh root login1. Login to your server as root user2. Open file...