Skip to content

GeoIP converter from txt file with list of network subnets to compiled dat file for further usage with NGINX ngx_http_geoip_module module

License

Notifications You must be signed in to change notification settings

RussellSk/GeoIP-txt2dat-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GeoIP-txt2dat-converter

This is a simple converter from "txt" file with list of network subnets to GeoIP "dat" format. GeoIP "dat" file further may be used with NGINX ngx_http_geoip_module module wich creates variables with values depending on the client IP address, using the precompiled GeoIP databases.

Requirements:

txt2csv.py works on Python3
csv2dat.py works on Python2

Python2
pip install ipaddr
pip install pygeoip

Linux:
apt-get install ipcalc
apt-get install aggregate

Usage:

Input txt file example:

31.40.24.0/22
31.135.208.0/21
31.148.144.0/22
31.148.208.0/22
37.110.208.0/21
46.8.35.0/24
46.227.120.0/21

Convert TXT file with network subnets to CSV file
python3 ./txt2csv.py -i test.txt -o test2_output.csv

Convert CSV file to DAT format
python csv2dat.py -w mmcountry.dat mmcountry ./test2_output.csv

About

GeoIP converter from txt file with list of network subnets to compiled dat file for further usage with NGINX ngx_http_geoip_module module

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages