Skip to content

Look up IP geolocation with curl

You can geolocate any IP address — not just your own — straight from the terminal. Append ?ip= to any endpoint and ipconfig.io returns what it knows: country, city, coordinates, time zone, and the owning network.

Geolocate one address

sh
curl ipconfig.io/json?ip=1.1.1.1
json
{
  "ip": "1.1.1.1",
  "ip_decimal": 16843009,
  "country": "Australia",
  "country_iso": "AU",
  "country_eu": false,
  "asn": "AS13335",
  "asn_org": "Cloudflare, Inc.",
  "hostname": "one.one.one.one"
}

Just one field

When you only want a single value, the plain-text endpoints skip the JSON entirely:

sh
curl ipconfig.io/country?ip=8.8.8.8        # United States
curl ipconfig.io/coordinates?ip=8.8.8.8    # 37.751000,-97.822000
curl ipconfig.io/asn-org?ip=8.8.8.8        # Google LLC

Parse JSON with jq

Pipe /json into jq to pull out exactly what you need:

sh
# country and network in one line
curl -s ipconfig.io/json?ip=1.1.1.1 | jq -r '"\(.country) — \(.asn_org)"'
# Australia — Cloudflare, Inc.

# just the coordinates
curl -s ipconfig.io/json?ip=8.8.8.8 | jq -r '"\(.latitude),\(.longitude)"'

Look up a list of addresses

A shell loop is enough for a quick batch:

sh
for ip in 1.1.1.1 8.8.8.8 9.9.9.9; do
  echo "$ip -> $(curl -s ipconfig.io/country?ip=$ip)"
done
1.1.1.1 -> Australia
8.8.8.8 -> United States
9.9.9.9 -> United States

How accurate is IP geolocation?

Country and ASN are reliable. City and coordinates are best-effort and can be off by a region — they're derived from MaxMind GeoLite2, not GPS. Anycast and infrastructure addresses (like 1.1.1.1) often have no city at all, because they aren't pinned to one location. Never treat IP geolocation as a precise position.

Fields you can read

Every field — country, city, region_name, latitude, time_zone, asn and the rest — is documented in the API reference.

Geolocation by MaxMind GeoLite2. No tracking, no keys.