Difference between revisions of "How to block someone's IP"

From Kolmisoft Wiki
Jump to navigationJump to search
Line 14: Line 14:


Please read this link http://www.debian-administration.org/articles/445
Please read this link http://www.debian-administration.org/articles/445
Question: I want allow only specified IPs to my server and dissallow any other connections, how I could do that?
First of all enter all friendly ips:
  iptables -A INPUT -s friendlyip. -j ACCEPT
  iptables -A INPUT -s another.friendly.ip -j ACCEPT
And the most end enter:
  iptables -A INPUT -s 0/0 -j DROP
Thats it.
If in future you will want to add some more ips, just first reject rule with DROP, and some friendly ip and then apply DROP rule again.
'''Very important:''' Don't forget to add ISP/router to your friendly ip address list!!!

Revision as of 13:36, 6 January 2009

To block incoming IP, use this command:

   iptables -A INPUT -s IP -j DROP

For example:

   iptables -A INPUT -s 123.123.123.123 -j DROP

To save the rules, run:

On Centos)

  /etc/init.d/iptables save

On Debian)

Please read this link http://www.debian-administration.org/articles/445


Question: I want allow only specified IPs to my server and dissallow any other connections, how I could do that?

First of all enter all friendly ips:

 iptables -A INPUT -s friendlyip. -j ACCEPT
 iptables -A INPUT -s another.friendly.ip -j ACCEPT

And the most end enter:

 iptables -A INPUT -s 0/0 -j DROP

Thats it.

If in future you will want to add some more ips, just first reject rule with DROP, and some friendly ip and then apply DROP rule again.

Very important: Don't forget to add ISP/router to your friendly ip address list!!!