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