Last Updated: February 25, 2016
· logikal

Get your public IP from the command line

[~] curl
8.8.x.x checks for the curl useragent, and gives you only the data you're looking for. Nice of them.

They've got a bunch of other useful URLs, usable from the command line, including hostname (useful for Amazon Route53 CNAMEs, for instance), useragent, language, etc:

[~] curl
[~] curl
url/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
[~] curl

You can also get everything as JSON:

[~] curl
"connection":"","ip_addr":"","lang":"","remote_host":"some.long.hostname.tld","user_agent":"curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5","charset":"","port":"61888","via":"","forwarded":"","mime":"*/*","keep_alive":"","encoding":""}

There's a table of all the URLS at, just scroll down past your info.

Inspired by @tonyseek's protip: Getting Local Machine IP Address in Shell.