TransWikia.com

MaxMind GeoIP CSV to .dat

Server Fault Asked by yax on February 12, 2021

I need to put local IP addresses into MaxMind GeoIP DB.
I’ve downloaded the CSV and adding new IP addresses and locations is easy.
I’ve found two tools that do csv to dat for MaxMind GeoIP but I can’t get them work.

With python script:

./csv2dat.py -w custom_geoip.dat mmcountry working.csv 
File "./csv2dat.py", line 69
print "error: database types don't match"
SyntaxError: Missing parentheses in call to 'print'

Also, I’ve tried to compile cpp script (https://github.com/dankamongmen/sprezzos-world/blob/master/packaging/geoip/debian/src/geoip-csv-to-dat.cpp) but I get large strace.

I’ve tried with new and old MaxMind DB. is there any other tool?

Thanks

One Answer

geoip-csv-to-dat.cpp - is the part of geoip-bin package and could be installed from Debian or Ubuntu repository if it is your linux distributive.

apt-get install geoip-bin
/usr/lib/geoip/geoip-generator --help

UPDATE: digging into the source uncovered that maxmind country and city csv databases got completely different formats so you have to provide different bunches of arguments to process it.

For country database:

/usr/lib/geoip/geoip-generator -v -o custom_geoip.dat working.csv 

For city database:

/usr/lib/geoip/geoip-generator -v -o custom_geoip.dat -t 
GEOIP_CITY_EDITION_REV1 -l working-locations.csv working-blocks.csv 

As for csv2dat.py - looks like you are trying to execute Python 2 script with Python 3 interpreter. Try:

python2.7 csv2dat.py -w custom_geoip.dat mmcountry working.csv 

Answered by Alexander Klimenko on February 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP