#1  
Old 22nd July 2012, 00:46
oyo oyo is offline
Junior Member
 
Join Date: Jul 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Mass block subnets

Hi,
I'm running ISPC3 on Ubuntu 11.04, and is looking for a good way to mass block subnets (basically countries), and not f**k things up with ISPC.
I'm thinking of using this page as a source for IPs.

I've been searching, and found this that looks almost perfect but, the only thing is that I want to block with the format ip 1.2.3.4/24,
and also I'm not sure if this script is compatible with ISCP3? Anyone have some input on that?

I also found this link, but I don't want to do it all manually, when its tens of thousand of subnets! Anyone have a script that can do the same thing, but read the subnets from a file?

Or does anyone have some other good advice for me?
Reply With Quote
Sponsored Links
  #2  
Old 22nd July 2012, 16:18
pititis pititis is offline
Senior Member
 
Join Date: Dec 2010
Location: München
Posts: 364
Thanks: 39
Thanked 89 Times in 68 Posts
Default

Try this script


Code:
#!/bin/bash

_input=countries.txt
IPT=/sbin/iptables
$IPT -N COUNTRIES-BLACKLIST
while IFS= read -r ip
do
	$IPT -A COUNTRIES-BLACKLIST -i eth0 -s $ip -j DROP
	done < "$_input"
	$IPT -I INPUT -j COUNTRIES-BLACKLIST
	$IPT -I OUTPUT -j COUNTRIES-BLACKLIST
	$IPT -I FORWARD -j COUNTRIES-BLACKLIST
and put the subnets in the countries.txt file:
Code:
60.160.0.0/15
223.165.4.0/22
run the script and test iptables:

Code:
iptables -L COUNTRIES-BLACKLIST -n
Cheers!
Reply With Quote
  #3  
Old 26th July 2012, 12:49
chrislim2888 chrislim2888 is offline
Junior Member
 
Join Date: Jul 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default

For block countries list, you can easily get it from various free site, like, https://www.ip2location.com/free/visitor-blocker
Reply With Quote
Reply

Bookmarks

Tags
block a country, block ip, iptables

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Forwarding SPAM to quarantine. tomrichmond Server Operation 8 20th April 2011 19:50
WebDAV doesn't start - DAVLockDB not created - error 405 Method not allowed maljam Server Operation 2 23rd March 2011 17:06
Free service to block online visitors by country in Apache Web server mialye Server Operation 0 1st October 2009 06:54
can't make work joomla + sef + .htaccess bochenn General 9 4th April 2007 14:47


All times are GMT +2. The time now is 09:30.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.