Geoip Update Database

ip bash geoip

How to install the “geoipupdate” software from MaxMind.

Create an account on Maxmind for GeoLite2. Go to:

https://www.maxmind.com/en/geolite2/signup

Download and extract the appropriate tarball for your system.

You will end up with a directory named something like geoipupdate_4.0.0_linux_amd64 depending on the version and architecture.

Copy geoipupdate to where you want it to live. To install it to /usr/local/bin/geoipupdate, run the equivalent of sudo cp geoipupdate_4.0.0_linux_amd64/geoipupdate /usr/local/bin.

geoipupdate looks for the config file /usr/local/etc/GeoIP.conf by default.

add-apt-repository ppa:maxmind/ppa
apt update ;  apt upgrade ;  apt install geoipupdate

Before you can run the geoipupdate script, you’ll have to add our own credentials on /etc/GeoIP.conf

You should have already file called GeoIP.conf, if not you can copy paste:

 $ nano /etc/GeoIP.conf
# Please see https://dev.maxmind.com/geoip/geoipupdate/ for instructions
# on setting up geoipupdate, including information on how to download a
# pre-filled GeoIP.conf file.

# Enter your account ID and license key below. These are available from
# https://www.maxmind.com/en/my_license_key. If you are only using free
# GeoLite databases, do not uncomment these lines.
 AccountID 0
 LicenseKey 000000000000
 EditionIDs GeoLite2-ASN GeoLite2-City GeoLite2-Country

More help here : https://dev.maxmind.com/geoip/geoipupdate/

run the commande :

$ geoipupdate -v
 geoipupdate 3.1.1
 Opened License file /etc/GeoIP.conf
 AccountID 154662
 LicenseKey g6oO...
 Insert edition_id GeoLite2-ASN
 Insert edition_id GeoLite2-City
 Insert edition_id GeoLite2-Country  
 Read in license key /etc/GeoIP.conf
 Number of edition IDs 3
 url: https://updates.maxmind.com/app/update_getfilename?product_id=GeoLite2-ASN
 url: https://updates.maxmind.com/geoip/databases/GeoLite2-ASN/update?db_md5=4a65a4c119ba21dd62858eec0
 No new updates available
 url: https://updates.maxmind.com/app/update_getfilename?product_id=GeoLite2-City
 url: https://updates.maxmind.com/geoip/databases/GeoLite2-City/update?db_md5=0cf0e7a0b9649404168f52a0c8
 No new updates available
 url: https://updates.maxmind.com/app/update_getfilename?product_id=GeoLite2-Country
 url: https://updates.maxmind.com/geoip/databases/GeoLite2-Country/update?db_md5=c479e178147c347394f21ef873
 No new updates available

( You need to file AccountID, LicenseKey, EditionIDs to run successfully the script.)


We are finally ready to update our MaxMind GeoLite database!

If that command succeeds, you can now execute the geoipupdate script below.

   mkdir /var/www/app/cache/ip_data
   sudo -u daemon geoipupdate -f /etc/GeoIP.conf -d /var/www/app/cache/ip_data -v
   chmod -R 777 /var/www/html/app/cache/ip_data

Because we added the -v option at the end, the script execution will respond with some data about the process and the results.

Previous Post