| 1 |
Automatically fetching GeoIP "free" databases
|
| 2 |
==============================================
|
| 3 |
|
| 4 |
As provided by Maxmind, LLC, the GeoIP library packages possess tools to
|
| 5 |
fetch the licensed country/city/organization etc. databases they
|
| 6 |
provide, but no such tool to fetch the free Country/City equivalents.
|
| 7 |
|
| 8 |
Additionally, the database version shipped with the base package will be
|
| 9 |
the current one at the time a new library release ships. Therefore, the
|
| 10 |
shipped database gets less accurate and obsolescent if the library has
|
| 11 |
not been updated in some time.
|
| 12 |
|
| 13 |
Therefore these databases can become out-of-date quite quickly unless
|
| 14 |
the user manually fetches and replaces them regularly; Maxmind generally
|
| 15 |
release updates once a month (on the 1st/2nd day of the month).
|
| 16 |
|
| 17 |
To assist users/administrators in automating retrieval/updating of the
|
| 18 |
available free databases, I've provided the following Perl scripts:
|
| 19 |
|
| 20 |
THE SCRIPTS:
|
| 21 |
===========
|
| 22 |
|
| 23 |
* fetch-geoipdata.pl - This fetches the base GeoIP.dat.gz file from
|
| 24 |
Maxmind's site, replacing the existing /usr/share/GeoIP/GeoIP.dat file
|
| 25 |
appropriately, keeping a dated backup (YYYYMMDD) of the old database file.
|
| 26 |
|
| 27 |
* fetch-geoipdata-city.pl - This works the same way as the above script,
|
| 28 |
but on the free City database. It should be noted that a) the City database
|
| 29 |
is not part of the standard library package and b) it's fairly large
|
| 30 |
(~20mb) and not friendly to users on slow connections.
|
| 31 |
|
| 32 |
File location and URL to fetch from are in the script itself, feel free
|
| 33 |
to change these to suit your system and local requirements.
|
| 34 |
|
| 35 |
REQUIREMENTS:
|
| 36 |
============
|
| 37 |
* A basic Perl installation will do. As long as Carp, File::Copy and the
|
| 38 |
LWP modules are available the scripts will be satisfied
|
| 39 |
* gzip to decompress the fetched archives. Almost all systems will have
|
| 40 |
this as part of the base installation.
|
| 41 |
|
| 42 |
USAGE:
|
| 43 |
============
|
| 44 |
* Simply put the scripts in your PATH and set them to executable.
|
| 45 |
|
| 46 |
* These are best run from a crontab entry, ideally on the 1st/2nd of the
|
| 47 |
month (depending on your timezone. I'm at +1000 - Queensland,
|
| 48 |
Australia so that works for me)
|
| 49 |
|
| 50 |
eg
|
| 51 |
|
| 52 |
# Fetch GeoIP databases at 6am on the 2nd of the month
|
| 53 |
00 06 2 * * /usr/local/bin/fetch-geoipdata.pl
|
| 54 |
|
| 55 |
You should not need to reload apps using the databases under normal
|
| 56 |
circumstances.
|
| 57 |
|
| 58 |
BUGS:
|
| 59 |
============
|
| 60 |
* Hopefully few if any. More verbose error checking is planned.
|
| 61 |
* Please do not send bug reports or issues relating to these scripts to
|
| 62 |
Maxmind, LLC - I am in no way employed by or personally/professionally
|
| 63 |
related to the company, I'm just a user like you :-)
|
| 64 |
* Feel free to send any improvements / bugfixes / ideas to me directly.
|
| 65 |
|
| 66 |
AUTHOR
|
| 67 |
============
|
| 68 |
Michael Fleming <mfleming@enlartenment.com>
|
| 69 |
|
| 70 |
LICENSE
|
| 71 |
============
|
| 72 |
This code is licensed under the GPL version 2
|
| 73 |
|