Skip to content

Instantly share code, notes, and snippets.

@ksaver
Created April 15, 2018 23:37
Show Gist options
  • Save ksaver/d4521a67e44b82f401f93b8e4d4d374a to your computer and use it in GitHub Desktop.
Save ksaver/d4521a67e44b82f401f93b8e4d4d374a to your computer and use it in GitHub Desktop.
Geolocate an IP address
#!/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
@ksaver
Copy link
Author

ksaver commented Apr 15, 2018

$ 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"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment