← All one-liners·#014·diagnostics·self contained·beginner

What's my IP and where is it?

Free public API for your IP plus city/country/ISP/timezone. One curl, one jq, done.

The one-liner
$ curl -fsSL -A 'Mozilla/5.0 oneliner101' https://ifconfig.co/json \
  | jq -r '"\(.ip)\t\(.city), \(.country)\t\(.asn_org)\t\(.time_zone)"'
What each stage does
  1. [01] curlcurl -fsSL -A 'Mozilla/5.0 oneliner101' https://ifconfig.co/json
    ifconfig.co's anonymous JSON endpoint — no key, no Cloudflare challenge. `--fail` (-f) surfaces 4xx/5xx instead of silently piping an HTML body into jq. The `-A` user-agent is best-practice on every public endpoint; some hosts (Wikipedia, Reddit) outright require it.
  2. [02] jqjq -r '"\(.ip)\t\(.city), \(.country)\t\(.asn_org)\t\(.time_zone)"'
    String interpolation: `\(.field)` inserts a field into a literal. -r emits raw text. Tab-separated so you can pipe to `column -t` if you want alignment.
Expected output (sample)
176.1.76.41	Werne, Germany	Telefonica Germany	Europe/Berlin
Caveats & tips
  • If you're behind a VPN/proxy, you see the egress IP, not your LAN IP.
  • For deeper data (ASN number, lat/long, country_iso), drop `-r` and jq the whole object.
  • IPv6 responses on some networks omit city/region_name; jq emits `null` gracefully but the city field may be empty.