Retrieve Your Public IP Address From The Command Line.
There are many reasons that you want to know your public IP address and getting that is easy by visiting some of the sites that allow you to view that information, but what if you wanted to do it from the command line? What if you wanted to script that? To upload the result to a web page? Or to email it?
There is a quick and easy way of doing it from the command line.
In Linux or any other UNIX based system, open terminal window or ssh to your server and type the following at the command prompt.
wget -qO - http://www.whatismyip.org
In Windows, if you haven’t done already, download and wget from this location, extract it to your c:\Windows or C:\Windows\system32 folder and then open a command line box and type the same command in the above in the command box.
On Linux/UNIX systems, curl http://www.whatismyip.org has the same result for the wget command above.
