How do I block an IP address in my Linux Server?

If you want to block an IP to access your linux server, you will need to login to the shell as root. Your server will either have the ipchains or iptables firewall to help accomplish this.

In this example, the attacking IP is

If you are using ipchains type: ipchains -A input -j DENY -p all -l -s

If you are using iptables type: iptables -A INPUT -s -j DROP

If you just want to block access to one port from an IP:

iptables -A INPUT -s -p tcp -destination-port 80 -j DROP

The above would drop all packets from to port 80 (HTTP) on your server.

  • DDOS, Security
  • 63 Users Found This Useful
Was this answer helpful?

Related Articles

Do you provide DDoS protection? How does it work?

We provide inbound DDoS filtering options for all our services where stated.DDoS Protection is...

How to check if your Linux server is under DDOS Attack?

Login to your server as root and fire the following command, using  which you can check if your...

How to Harden PHP in WHM/cPanel Servers

PHP exploits are responsible for the vast majority of compromised servers. OverviewThis document...