Using perl, install IO::Interface::Simple from CPAN: $ cpanm --sudo install IO::Interface::Simple
Then do: $ perl -MIO::Interface::Simple -e 'print IO::Interface::Simple->new("eth0")->address, "\n"'
Frank I have the following setup on my server: http://vigeek.net/extip.php
Same scenario as what Fred suggested, just curl that URL.
On Tue, Jan 8, 2013 at 11:44 AM, Fred Stluka <fred@bristle.com> wrote:
Sam,
Try:
% curl http://automation.whatismyip.com/n09230945.asp
--Fred
------------------------------------------------------------------------
Fred Stluka -- mailto:fred@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.
------------------------------------------------------------------------
On 1/7/13 12:56 PM, Sam Gleske wrote:
Yet I've found that most times I'm able to reliably turn to the */proc* filesystem for stuff like this. I'm just curious if anyone has found a decent way to do this since that thread was originally posted.
I wonder if parsing a combination of */proc/net/fib_trie* and */proc/net/route* would be useful in finding the IP address of the default route (which I would assume be the internet connected IP address). I found fib_trie by grep -irl my IP address through /proc. Here's some kernel documentation on fib_trie but there's nothing useful about using it for obtaining the IP address of the default route.
___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|