|
Pages: [1] |  |
|
|
Author
|
Topic: Blocking an IP range using iptables (Read 11804 times)
|
 Joined: Sep 2008 Posts: 44

United States
|
Sep 21, 2008, 05:13:20 PM | #1 |
I'm posting this here to help any of you out who need to use iptables firewall to block offensive IP ranges...
If you wanted to block the entire 221.0.0.0-221.255.255.255 range, then use either:
iptables -I INPUT -s 221.0.0.0/255.0.0.0 -j DROP iptables -I INPUT -s 221.0.0.0/8 -j DROP
They do the same thing, you're just using CIDR notation instead of netmasks...
Note that using /24 will just block 221.0.0.0-221.0.0.255 as in the command below
iptables -A INPUT -s 192.168.100.0/24 -j DROP
To block a single IP, just do the following
iptables -I INPUT -s 83.69.224.164 -j DROP
|
|
|
|
| |
|
|
|
    Joined: Jan 2006 Posts: 6215
Administrator
 
 United States
|
Oct 04, 2008, 06:40:30 PM | #3 |
Here's a good article on doing it with your .htaccess file
http://www.kirupa.com/web/htaccess.htm
basicly...
* IP Blocking If you would like to prevent an individual or a group of individuals on a certain IP range from accessing your site, you can selectively deny access to them. You would use the following command format:
<Limit GET HEAD POST> order allow,deny deny from 18.52.3.5 deny from 18.132.152 deny from 24.2 allow from all </LIMIT>
Of course, you would probably not be interested in blocking the fictitious IPs I mentioned above. You should change those to something more relevant. If you are really not well liked, you can add as many deny from lines of code as you want.
If somebody from an entire IP range is bugging, you can block all IPs within that range by only entering a smaller portion of their IP such as 24.2. All IPs that being with 24.2 such as 24.2.35.3 and 24.2.142.122 will also be blocked automatically. You may want to be careful for you may not want to block access to visitors that you still want accessing site.
While it's not as effective as using your firewall, if you don't have administrator priveleges on your server, the .htaccess file is a quick and dirty way to block offending IPs.
Also, see the following thread for generating IP blocks to block IP's by country...
http://www.code4gold.com/forums/index.php?topic=15691.0
|
|
Latest Blog Post :
8 Tips for Creating a Marketing Buzz
|
|
|
|
|
|
|
|
|
|
|
 |
|
Pages: [1]
|
|
|
 |