is ipapi csv's conversion supported?
i want to use the csv DB file from https://ipapi.is/developers.html#geolocation-database but when i try to convert it with:
mmdbctl import --in geolocationDatabaseIPv4.csv --out data.mmdb
i get error:
err: couldn't parse cidr "4/32": invalid CIDR address: 4/32
Why is it giving this error? Is it possible you can see if you can make this conversion for ipapi csv's compatible with mmdbctl?
thanks in advance
ps: surprised no-one has mentioned ipapi.is db's
Hi, I took a look at the database and it seems that the CSV database is not consistent.
mmdbctl import --in data.csv --out data.mmdb
Output
warn: couldn't insert line '154.17.129.024,154.17.129.024,EU,PL,Poland,Mazovia,Warsaw,05-077,Europe/Warsaw,52.22977,21.01178,1'
warn: couldn't insert line '185.208.9.024,185.208.9.024,EU,FR,France,Île-de-France,Paris,75998 CEDEX 14,Europe/Paris,48.85341,2.3488,1'
warn: couldn't insert line '60.54.50.0,0.0.0.0,AS,MY,Malaysia,Selangor,Putra Heights,47130,Asia/Kuala_Lumpur,2.9679,101.653,1'
warn: couldn't insert line '60.54.51.0,0.0.0.0,AS,MY,Malaysia,Selangor,Putra Heights,47130,Asia/Kuala_Lumpur,2.9679,101.653,1'
Please note the following:
185.208.9.024
The 024 contains the starting digit of 0, which results in the mmdbctl database declaring it to be an invalid IP address. This should be 185.208.9.24.
IPapi.is recognizes IP address to be valid: https://api.ipapi.is/?q=185.208.9.024
But IPinfo does not: https://ipinfo.io/185.208.9.024/json
60.54.51.0,0.0.0.0
This is not a valid IP range as the end_ip value precedes the start_ip value.
If the IP database can return consistent and valid rows, there should be no problem using mmdbctl to convert the CSV dataset to the MMDB dataset.
In the meanwhile, feel free to check out IPinfo's free IP database: https://ipinfo.io/products/free-ip-database
Let me know what you think. Thanks!
@jkuj6
I noticed that you are trying to set up NGINX with a geolocation database. You can check out IPinfo's free IP to Country database for that. Here are the instructions: https://ipinfo.io/blog/nginx-for-access-control-and-privacy-policies/
Fixed in commit https://github.com/ipapi-is/ipapi/commit/ec751295c80e502ae8b67cba7f6b7d53e9a71346 You should be able to convert it now.
How does my CSV file need to be structured in order to read it into MMDB format?
mmdbctl import --in geolocationDatabaseIPv4.csv --out data.mmdb
fails with
err: couldn't parse cidr "4/32": invalid CIDR address: 4/32
My file does not contain CIDR ranges. That's a strange error.
My file looks like this:
ip_version,start_ip,end_ip,continent,country_code,country,state,city,zip,timezone,latitude,longitude,accuracy
4,5.189.37.0,5.189.37.255,EU,RU,Russia,Свердловская Область,Yekaterinburg,901079,Asia/Yekaterinburg,56.8519,60.6122,2
4,185.67.40.0,185.67.40.255,EU,NO,Norway,Nordland,Bodø,8108,Europe/Oslo,67.2981512081068,14.399771690368652,2
4,185.46.121.0,185.46.121.255,NA,US,United States,Noord-Holland,Amsterdam,1109,Europe/Amsterdam,52.36889170602552,4.8944091796875,2
4,185.46.122.0,185.46.122.255,NA,US,United States,Noord-Holland,Amsterdam,1109,Europe/Amsterdam,52.36889170602552,4.8944091796875,2
4,185.46.123.0,185.46.123.255,NA,US,United States,Noord-Holland,Amsterdam,1109,Europe/Amsterdam,52.36889170602552,4.8944091796875,2
Hi,
The mmdbctl tool accepts files in a CSV format that begin with start_ip and end_ip columns. The first column of the IPapi.is IP database is ip. If you remove that column and try again, it will work. Can you please check? Thanks.
Remove first column from the database:
cut -d, -f2- geolocationDatabaseIPv4.csv > data.csv
Then convert:
mmdbctl import --in data.csv --out data.mmdb
that works like a charm and yields:
writing to data.mmdb (1347178 entries)
Looks like the issue has been resolved. Feel free to reopen if the problem persists. Thank you.