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

In reply to Re: GeoIP revisited by Tux
in thread GeoIP revisited by cavac

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.