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 to use iptables?

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

What is SSH and its basic useful commands?

SSH or Secure Shell is a way to manage a dedicated server remotely by using integrated Linux...

How to install rkhunter ?

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

How to protect server from Brute Force Attacks?

Here are a few of the many security options the WHM/cPanel has built in to protect your cPanel...

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...