Quantcast
Channel: SuSE Linux – The Wiert Corner – irregular stream of stuff
Viewing all articles
Browse latest Browse all 217

Getting your public IP address from the command-line

$
0
0

Many sites giving your public IP address return a web page with a bloat of html. From the command-line, you are usually only interested in the IP-address itself. Few services return exactly that.

Below are command-line examples to provide the public IP address mostly from a *nix perspective. Usually you can get similar commands to work with Windows binaries for wget and Windows binaries for curl.

In the end, I’ve opted for commands in this format, as I think akamai will last longer than the other sites (but does not include an end-of-line in the http result hence the echo on Mac/*nix):

I’ve not tried aria2 yet, but might provide commands for that in the future.

These are the Linux permutations for akamai:

curl whatismyip.akamai.com && echo
curl ipv4.whatismyip.akamai.com && echo
curl ipv6.whatismyip.akamai.com && echo
curl ipv4.whatismyip.akamai.com && echo && curl ipv6.whatismyip.akamai.com && echo

The last two are convenient when you have both IPv4 and IPv6 configured on “the outside”.

You can replace curl with wget -q -O – (which outputs to stdout) for each command. You can even ommit the http:// (as that is the default protocol for both curl and wget).

These get you plain text:

Telnet:

  • telnet myip.gelma.net

These get slightly more, but not much more than the plain IP address:

Thanks to these links that helped me find out about the above services.

If you ever want to run your own Dynamic DNS service (DDNS): http://andrwe.org/linux/own-ddns

–jeroen


Filed under: *nix, *nix-tools, Apple, bash, bash, Batch-Files, cURL, Development, Linux, Mac, MacBook, MacBook Retina, MacBook-Air, MacBook-Pro, MacMini, OS X, OS X Leopard, OS X Lion, OS X Maverick, OS X Mountain Lion, OS X Snow Leopard, OS X Tiger, OSX Yosemite, Power User, Scripting, Software Development, SuSE Linux, wget

Viewing all articles
Browse latest Browse all 217

Trending Articles