There are many times when I needed to find out my outgoing (or external) IP for the servers which are behind load balancers or firewalls.Â I used to just login to another external server from the server in question and find out by looking at “who” what my external ip is.Â Even though it works and I am so used to it, today I decided to figure out a more graceful way of finding my outgoing ip.Â As most of us already know, whatismyip.com is the quickest way to find out your outgoing ip from the browser.Â So I decided to use the same way on the servers.Â So I issued a wget:
Well that does the trick.Â But being lazy as I am, I did not want to have to cat the output file to find out the ip (plus there is no point of creating extra files and doing extra work to remove them).Â So if you are ssh’ed in, you can issue following command (I am sure there is another way of doing it, but this is the quickest way I could think of):
wget -q -O - http://www.whatismyip.org
-O tells wget to redirect output to the following file (- being the standard out ).Â So it basically echo’s output to our console.
-q makes wget run inÂ quiet mode so you do not see all of the connection/download/etc output.
That is it!Â I am curious to know what other ways people use to get the same information.Â Please share your way if possible.
DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. Use at your own risk.