Created
April 15, 2018 23:37
-
-
Save ksaver/d4521a67e44b82f401f93b8e4d4d374a to your computer and use it in GitHub Desktop.
Geolocate an IP address
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# geolocate an IP address | |
if [ -z $1 ]; then | |
echo "Missing argument: IP address." | |
else | |
IP=$1 | |
curl http://api.db-ip.com/v2/free/$IP | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ geolocateip.sh $(dig +short facebook.com)
{
"ipAddress": "157.240.19.35",
"continentCode": "NA",
"continentName": "North America",
"countryCode": "US",
"countryName": "United States",
"stateProv": "Texas",
"city": "Dallas"
}