Online GeoIP Lookups Using ipinfo.io

screen-shot-2016-10-30-at-1.00.39-pm-1-e1477858066473

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!

Related posts: