Article

Module in Perl for WorldIP-database

Thanks to Craig MacKenna, there is the module IP::World for WorldIP base in CPAN.
Today it is the fastest module for access to IP database. At Athlon64 2.4GHz are 236K req/sec; XEON E5405 2Ghz - 267K req/sec

The installation is very simple:
cpan -i IP::World
In your Perl programs it can be used as follows:
use IP::World;
my $ipw = IP::World->new(0);
print $ipw->getcc("123.45.67.89");
Or you can take a small command line utility ip2country based on this module, either interactively or in the command line:
echo "3.4.5.6" | ./ip2country
./ip2country 3.4.5.6
Along with the module, there is an utility maint_ip_world_db, it checks the currency of the database. It's enough to put it in the monthly/weekly cron.
Yuri Israel08 Nov 2010 14:11#2975English   
Hi,

I've seen mentions of GeoIP databases being used against DoS attacks - for example, a user would like to block all communication from Zimbabwe to their network, they would like to issue a request (to this perl module as an example, or the API) with "Zimbabwe" as input, and receive back the entire address space that belongs to the input country (in netmasks/CIDR/etc.), which they can later push to their routers/firewalls/etc.

Is there any existing API/module that can output the address space for an input country?

Regards,
Yuri
wipmania logo Alrond 21 Nov 2010 05:11#3023English   
They are 3 methods available:
1) Firewall level: iptables with geoip module and worldip database
2) Webserver level: you can choice only "right" countries in worldip.conf. For example, with
cat worldip.conf | grep -E 'US|CA|DE|FR|GB' > worldip.good.conf
And put in nginx config something like:
 geo  $geo {

       include  worldip.good.conf;
       default  0;
   }
location / {
       if ($geo = 0) { return 403; }
       ...
   }

3) Generally, you can select your countries from the text or nginx databases:
cat worldip.conf | grep -E 'US|CA|DE|FR|GB' > worldip.my.conf

Anonymous/Name OpenID OpenID Yahoo! OpenID AOL WordPress LiveJournal TypePad Vox Myvidoop Orange Yandex YandexBlog Mixi Myspace Flickr Verisign MyOpenID ClaimID

All fields are not required

Leave blank for main post.
Comment - 5000 characters maximum. BBcode is allowed.

Subscribe to answers: to all comments:RSS comments (en)

Please have a look at our
Facebook Page and leave a comment

Creative Commons License
Creative Commons Attribution-Noncommercial 3.0 License