Sign Up: https://www.maxmind.com/en/geolite2/signup
Web Page: https://dev.maxmind.com/geoip/geolite2-free-geolocation-data?lang=en
GeoLite2 database is a free IP geolocation database comparable to MaxMinds GeoIP2 database but less accurate than MaxMinds GeoIP2 database.
Country City and ASN data of GeoLite2 will be updated on the website every Tuesday.
Download: https://www.maxmind.com/en/accounts/716735/geoip/downloads
GeoLite2 provides a variety of data formats, this tool only parses CSV format
Usually download City and ASN data
City is the IP positioning data accurate to the city
ASN is the autonomous system information (the organization to which the IP belongs)
Take the CSV data of City as an example, decompress the downloaded compressed package, you can see many files language file IPV4 blocks IPV6 blocks LICENSE etc.
This tool parses GeoLite2 City: CSV Format and GeoLite2 ASN: CSV Format
The tool is a console program and can be run through the console. There are two versions DotNet core 5.0 DotNet Framework 4.0
DotNet core 5.0 is a cross-platform version but requires DotNet5 environment. Please refer to Microsoft"s official website for installation instructions: https://dotnet.microsoft.com/
DotNet Framework 4.0 requires .Net Framework 4.0 environment for Windows version Usually Win10 system already comes with it.
Run it with DotNet core
dotnet GeoLite2Helper.dll
Run it with Windows
GeoLite2Helper.exe
Output
GeoLite2Helper (search|create|server) ... ------------------------------------------------------------------------ search : search info from ip search [IP] [DBFile]+ e.g: search 8.8.8.8 db.loc e.g: search 8.8.8.8 db.asn e.g: search 8.8.8.8 db.loc db.asn e.g: search 8.8.8.8 db.asn db.loc create : create database file create (loc|asn) ... e.g: create asn GeoLite2-ASN-Blocks-IPv4.csv db.asn e.g: create loc City-Locations-zh-CN.csv City-Blocks-IPv4.csv db.loc server : run as server server (http|udp) [port] [local] [DBFile]+ http : run as http server http://localip:port?ip=8.8.8.8 udp : run as udp server recv:[ip] back:[result_json] local: (1/0) if local just bind 127.0.0.1, otherwrise 0.0.0.0 e.g: server http 8080 1 db.loc e.g: server udp 12345 0 db.loc e.g: server udp 12345 0 db.asn e.g: server http 8080 1 db.loc db.asn e.g: server http 8080 1 db.asn db.loc ------------------------------------------------------------------------ Powered by DebugST -> http://github.com/DebugST
The tool provides 3 modes: search create server
*.loc and *.asn are the tool custom database files *.loc is the IP location data *.asn is the IP autonomous system data, which are created by the tool through the CSV file.
create provides a database file customized according to the CSV file generation tool CSV file is the file mentioned in the above introduction
Format
GeoLite2Helper create (loc|asn) ...
loc means that to create an IP location database, the Language File and IPV4 files in the City download package are required.
GeoLite2Helper create loc [loc_file] [ipv4_file] [out_file] eg: GeoLite2Helper create loc GeoLite2-City-Locations-zh-CN.csv GeoLite2-City-Blocks-IPv4.csv db.loc
After running, the db.loc file will be generated.
asn means that the IPV4 file in the ASN download package is required to create the autonomous system database.
GeoLite2Helper create asn [ipv4_file] [out_file] eg: GeoLite2Helper create asn GeoLite2-ASN-Blocks-IPv4.csv db.asn
After running, the db.asn file will be generated.
search is a single search command
Format
GeoLite2Helper search [IP] [DBFile]+ eg: GeoLite2Helper search 223.5.5.5 db.loc GeoLite2Helper search 223.5.5.5 db.asn GeoLite2Helper search 223.5.5.5 db.loc db.asn GeoLite2Helper search 223.5.5.5 db.asn db.loc
You can choose to use one or both of the database files at the same time.
Example:
$ GeoLite2Helper search 223.5.5.5 db.asn db.loc ---------------------------------------------------------- { "asn": { "number": 37963, "name": "Hangzhou Alibaba Advertising Co.,Ltd." }, "location": { "geoname": { "locale_code": "zh-CN", "continent_code": "AS", "continent_name": "亚洲", "country_iso_code": "CN", "country_name": "中国", "subdivision_1_iso_code": "ZJ", "subdivision_1_name": "浙江省", "subdivision_2_iso_code": "", "subdivision_2_name": "", "city_name": "杭州", "metro_code": "", "time_zone": "Asia/Shanghai", "is_in_european_union": "0" }, "registered_country_geoname": { "locale_code": "zh-CN", "continent_code": "AS", "continent_name": "亚洲", "country_iso_code": "CN", "country_name": "中国", "subdivision_1_iso_code": "", "subdivision_1_name": "", "subdivision_2_iso_code": "", "subdivision_2_name": "", "city_name": "", "metro_code": "", "time_zone": "Asia/Shanghai", "is_in_european_union": "0" }, "represented_country_geoname": "", "is_anonymous_proxy": "0", "is_satellite_provider": "0", "postal_code": "", "latitude": "30.2994", "longitude": "120.1612", "accuracy_radius": "1000" } } //Note: The actual result is not formatted in JSON.
server is allowed in service mode Supports two service modes http udp.
http sends data in GET mode. The parameter is ip.
udp listens on port in UDP mode Accepts IP plain text Returns JSON data of this IP query result.
Format
GeoLite2Helper server (http|udp) [port] [local] [DBFile]+ port -> port for listen local -> Whether to listen to loopback addresses only (1 or 0) DBFile -> Database file. such as -> db.loc eg: //Starting the service in http mode takes effect on the local area network. GeoLite2Helper server http 8080 0 db.loc //Starting the service in udp mode only takes effect locally. GeoLite2Helper server udp 12345 1 db.asn //Starting the service in http mode takes effect on the local area network. GeoLite2Helper server http 8080 0 db.loc db.asn //Starting the service in http mode takes effect on the local area network. GeoLite2Helper server http 8080 0 db.asn db.loc
In http model, For local area need Administrator.
$ GeoLite2Helper server http 8080 1 db.asn db.loc ----------------------------------------------------- $ curl http://localhost:8080/?ip=8.8.8.8 ----------------------------------------------------- { ... //JSON data ... } //Note: The actual result is not formatted in JSON.
$ GeoLite2Helper server udp 12345 0 db.loc db.asn ----------------------------------------------------- $ nc -u localhost 12345 8.8.8.8 ----------------------------------------------------- { ... //JSON data ... } //Note: The actual result is not formatted in JSON.
Powered by DebugST -> http://github.com/DebugST