Skip to content
Alexey Zilber edited this page Jan 13, 2020 · 3 revisions

Using geoip2redis

All options may change. As of the current (0.0.3) version the following applies. Help

-a --redis-pass: This value is currently unused, as we don't have a password setup on our Redis (TODO).

-f --format: The format of the incoming CSV file. This currently is either ip2location or software77.

-i --input-precision: This does a few things, and while not required, it's HIGHLY RECOMMENDED you understand this option, and use it. Please read below to see what it does.

-p -r: Are self explanatory.

-s --skip-header: Whether or not to skip the CSV header. This is never needed unless you're trying to load an unknown format CSV file. Good luck!

-t --force-autodetect: This option is minimally tested, and most likely will not give you what you want. Format must still be specified, but it will try and figure out the DB header by looking at the number of columns. This is currently broken as the number of columns is not currently mapped. Try not to use.

Input Precision

"Input Precision" does different things depending on the format specified.

IP2Location

For ip2location this specifies the "db number". For example, ip2location distributes databases from 1 to 24, all with different data.
They're broken down into Redis subkey sets as 'DB1' .. 'DB24'. If you don't specify -i we'll try to guess, and right now, it's guaranteed to guess wrong.
So use the number of the DB name in the CSV file you downloaded. For example, for IP2LOCATION-LITE-DB1.CSV you would specify -i 1 and for IP2LOCATION-LITE-DB11.CSV you would specify -i 11

You may also use -i 0 which is a special case. It will generally write out the 0 value for the database header and do minimal processing based on the format specified.

Software77

Software77 provides an IPV4 CSV (gz) which is the file supported by GeoIP2Redis. When you specify -f software you have the option of using either -i 0 or -i 1 for the input precision. This will have the following effect:

  • -i 0: Loads the GEOIP CSV AS IS with only a minimal drop of the second column and fourth as needed for zrange.
  • -i 1: Loads and converts the database into the DB1 format of IP2Location

Here's an example of results when querying the same data: