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:
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.
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
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
And put in nginx config something like:
3) Generally, you can select your countries from the text or nginx databases: