- Unsupervised Learning
- Posts
- Online GeoIP Lookups Using ipinfo.io
Online GeoIP Lookups Using ipinfo.io
There are lots of ways to resolve an IP to a country/location. The fastest way is to have the database local and do quick checks against the file/database as needed.
But for quick hits it’s always nice to have an online options as well!
curl ipinfo.io/23.66.166.151
This gets you a nice little JSON object with the full results, as seen above.
Here are a few other filtering options:
# Get the country code of the result
curl ipinfo.io/23.66.166.151 | grep country | awk -F'”‘ ‘{ print $4 }’
# Get the state of the result
curl ipinfo.io/23.66.166.151 | grep region | awk -F'”‘ ‘{ print $4 }’
# Get the city of the result
curl ipinfo.io/23.66.166.151 | grep city | awk -F'”‘ ‘{ print $4 }’
Enjoy!