Sometimes you have a need to get the external IP on your server that you are working from. There is no easy command in shell to get the external IP address. A simple $ ifconfig will show you only your internal addresses and NAT or IP’s that have been bound to the servers NIC card. I am going to give you the code to run to get the external IP address from your server in shell(putty).
A lot of the information on the web suggests you use simple CURL or GET commands with http://whatismyip.org. The issue being it DOES NOT WORK ANYMORE. The site no longer produces a text verison of your IP, it now creates a image of your IP to serve it, most likly so only browser users use it and view advertising.
The great thing, is now there is an alternative, google now shows in in the results page for “what is my IP”, With this simple command you can grab the results of that query right in shell. The great thing being Google isn’t likley to change that anytime soon.
Here is the query, copy paste and run it in shell:
curl --silent 'http://www.google.com/search?q=what+is+my+ip' | sed 's/.*Client IP address: //;s/).*//;q'
This works in every instance of Red Hat EL and CentOS that I am running. Comment if it works successfully for you in another environment.