Finding public IP on Linux command line

Here’s a handy command to display the Internet facing IP on a Unix/Linux command line. This is particularly useful on systems where lynx is not available, and where the system might be behind a firewall so that the public IP cannot be discerned from ifconfig output.

curl -s myip.dk | grep 'IP Address' | egrep -o '[0-9.]{3,}+'