• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

getting external IP from unix command line

walla

Senior member
Is it possible to get the external IP address from some common unix command?

ifconfig -a will give me the local IP address...but thats not what I want.

I know that some websites can tell you the external IP. Thats not the solution I want. Ideally, I would like to be able to grep the output of some unix command and pipe it to an application that will monitor it.

One solution I can think of is use wget to get the html source of one of these webpages but that doesn't seem like the best solution.

Any other ideas?
 
i have found the following will work...

wget -O - http://www.whatismyip.com/ | grep 'Your IP is' | sed -e 's/.* is //' -e 's/ .*//'

Of course...if the site goes down or changes structure, my solution breaks. Thats what I want to avoid.
 
Of course...if the site goes down or changes structure, my solution breaks. Thats what I want to avoid.

The only way to avoid that would be to manage the external site yourself. You could always write a script using ssh (or telnet if you have a crappy router) to log into the router and get the IP from it's external interface.
 
Originally posted by: Nothinman
Of course...if the site goes down or changes structure, my solution breaks. Thats what I want to avoid.

The only way to avoid that would be to manage the external site yourself. You could always write a script using ssh (or telnet if you have a crappy router) to log into the router and get the IP from it's external interface.

Or you could just wget www.google.com/index.html, the chances of Google diving should be far smaller than your router taking a crap.
 
Or you could just wget www.google.com/index.html, the chances of Google diving should be far smaller than your router taking a crap.

Yes but with the ssh/telnet solution you could check for connectivity and also do something about it if you wanted to, like reboot the router or something. It really depends on how far you want to take this.
 
Back
Top