• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

Blocking a whole countries ip

Status
Not open for further replies.
There will be a lot of IP ranges for a specific country.

I have an uptodate database of ip-country database. Its hosted somewhere in the net.

Reply if u really need it.
 
Find out China's range of ips, the start of it anyway. and ban say 22.XX.XX.XX
That is an incredibly stupid way to do that! :p

Do you have any idea how many IP ranges you would have to block?

The best solution for that is to get mod_geoip from maxmind.com
and install the module for Apache which will add a new variable
to all visitor connections identifying their country.

Once that is installed, you could just put the following in .HTACCESS:
SetEnvIfNoCase GEOIP_COUNTRY_CODE (CN|HK) bad_country

<Files *>
Order Allow,Deny
Allow from all
Deny from env=bad_country
</Files>
(The above example would block CHINA and HONG KONG from your site)

New updates for the country database file for the module comes
out at the beginning of each new month and you can setup a cron job
easy enough to pull the new databases whenever they are released.

http://www.maxmind.com/app/geoip_country

For those unfortunate enough to be on reseller accounts or not
know how to compile apache modules, Maxmind also has a number
of other engines for PHP and Perl, etc which will do the same thing
from your scripts but doing it from Apache is always the cleanest
and fastest way of doing that.

http://www.maxmind.com/app/api
 
Yeah, and half the people in the world don't resolve. Check your awstats or something -- many will say unknown, or just an IP. ISP's sometimes dont feel like resolving all their IPs.
 
Yeah, and half the people in the world don't resolve. Check your awstats or something -- many will say unknown, or just an IP. ISP's sometimes dont feel like resolving all their IPs.
When you say "resolve" the way you put it, you are actually referring
to IPs having reverse DNS resolution to hostnames.

However, it is not necessary to obtain the reverse hostname in order
to determine the location of an IP address unless you are doing something
stupid such as "blocking .CN" like one user suggested.

Actually every IP on the planet will resolve to location with GeoIP
unless the user is on a Satellite connection but even then you can
still narrow things down pretty good.

Incidentally, if a server has GeoIP installed, AwStats can be configured to
use that for the Country identification and all your "Unknowns" in your
AwStats will suddenly be identified to their source location!
 
sounds like a neat peice of software, is that how you implement your system of not accepting ips from countries at different times ( i think you do anyway)
??
 
I have ben using it to block china for a long time. and afew other countrys
I won't name.

Works fine for me.

Zcoder....
 
Re AMZ above for info - and zcoder, what are you talking about?
Decker, just look at the first page of this thread ....

The software we are talking about is GeoIP from Maxmind

Basically in a nutshell, you have a compressed database on your server
that has the country and / or city locations of every IP address on
the internet and new updates are released each month that can be
easily downloaded by cron job.

Then you use either the Apache module or language plugins to enable
your server to make use of the database.

The Apache module is the coolest way to do it because you automatically
get 2 new server variables with every connection that give you the
country code and country name of every visitor connection!

It's a piece of cake to blacklist (or even whitelist) whole countries!

Using this technology also allows you to deliver different content
automatically based on the country of the visitor which is another
really cool thing you can do with GeoIP!

I pretty much consider GeoIP a "must install" item on all servers! :wave:
 
Status
Not open for further replies.
Back
Top