~ioiojo/ip-lookup

Get public IP and location of local machine
determine to use something besides jqnatividad/qsv

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~ioiojo/ip-lookup
read/write
git@git.sr.ht:~ioiojo/ip-lookup

You can also use your local clone with git send-email.

#ip-lookup

Get public IP and location of local machine

#Description

  • scripts/dbip-lite-to-sqlite3: Python script to convert DB-IP "IP to City Lite" CSV database to SQLite

  • scripts/ip-lookup: Python script to show public IP address of local machine - fancier alternative to curl -s https://api.ipify.org etc

  • scripts/ip-to-geolocation: Python script to convert IP address to geolocation - based on DB-IP "IP to City Lite" database

  • scripts/dbip-lite-to-sqlite3.sh: Bash version of scripts/dbip-lite-to-sqlite3 - very slow, introduces gawk and sqlite3 dependencies

  • scripts/dig-geoip.sh: simple Bash version of scripts/ip-to-geolocation - slow, introduces awk dependency, doesn't require passing IP address argument

  • scripts/ip-to-geolocation.sh: simplified Bash version of scripts/ip-to-geolocation - also returns ISP, but reliant on web services, introduces jq dependency

#Usage

#Step 1. Download DB-IP "IP to City Lite" database (CSV)

Warning: CSV file is over 500 MB as of May 2023.

#Step 2. Convert CSV to SQLite

# this only takes a few seconds
./dbip-lite-to-sqlite3 dbip-city-lite-YYYY-MM.csv dbip-city-lite-YYYY-MM.sqlite

dbip-city-lite-YYYY-MM.sqlite should be about half the size of the CSV.

#Step 3. Obtain public IP address

./ip-lookup

#Step 4. Convert public IP address to geolocation

./ip-to-geolocation <ip-address> dbip-city-lite-YYYY-MM.sqlite

#Credit

OpenAI GPT-4 wrote most of this code.

#License

Licensed under either of

at your option.

#Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Do not follow this link