Finding out public IP from console on Linux


My site of choice to lookup my public IP is http://www.whatismyip.com. This is very easy to use from a browser but not as straight forward if you only have access to the console. The trick is to use wget and a regular expression to extrac the IP address.

The script below is taken from wolfvorkian1 at http://ubuntuforums.org/archive/index.php/t-228660.html

wget -qO - www.whatismyip.com/automation/n09230945.asp | egrep -m1 -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'

This will just display your external public IP

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: