Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: GeoIP revisited

by Tux (Canon)
on Nov 26, 2018 at 12:59 UTC ( [id://1226331]=note: print w/replies, xml ) Need Help??


in reply to GeoIP revisited

My first stab at GeoIP2 is avalable on github:

$ git clone github.com:Tux/GeoIP2 geoip $ cd geoip $ wget -q -m -L -nd -np -nH \ http://geolite.maxmind.com/download/geoip/database/GeoLite2-ASN-CSV.z +ip \ http://geolite.maxmind.com/download/geoip/database/GeoLite2-City-CSV. +zip \ http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country-C +SV.zip $ echo "create database geoip;" | psql -f - CREATE DATABASE $ perl geoip Create table stamps Create table continent Create table country Create table ipv4 Create table provider Create table city Create table ipc4 Reading Country info ... Reading Country IPv4 info ... Reading Provider IPv4 info ... Reading City info ... Reading City IPv4 info ...

Note that loading the database will require quite a bit of memory and may cause your machine to feel sluggish while loading. On my laptop this took 400 seconds. Once the data is in the database, the queries are quick.

$ time perl geoip perlmonks.org GeoIP data for 66.39.54.27 - www.perlmonks.org: CIDR : 66.39.0.0/16 IP range : 66.39.0.0 - 66.39.255.255 Provider : pair Networks City : Pittsburgh, 508, 15203 Country : US United States Continent : North America Location : 40.4254 / -79.9799 (1000) 40°25'31.44" / -79°58' +47.64" https://www.google.com/maps/place/@40.4254,-79.9799,10z Timezone : America/New_York EU member : No Satellite : No Anon Proxy: No 0.112u 0.008s 0:00.69 15.9% 0+0k 0+0io 0pf+0w

Enjoy, Have FUN! H.Merijn

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1226331]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2025-06-19 20:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.