[ale] Pulling IP address from server.
Brandon Checketts
brandon at brandonchecketts.com
Mon Jul 27 12:29:08 EDT 2009
Atlanta Geek wrote:
> What is the best way to identify the server's IP address from
> ruby/perl/python/C.
> I found a chunk of code parsing the results of ifconfig and I'm always
> concerned when I see this type of thing.
>
> Also does changing the default language of a server affect the output
> of these commands at all.
>
Seems like it should be contained somewhere in /proc, but I'm unable to
locate it there in a reliable way. I can see it in reverse hex in some
of the tables, but not in anything that authoritatively lists the IP
addresses on a machine.
I looked through the output of 'strace ifconifg' to see where ifconfig
is getting it from, and it looks like it may come from
/proc/net/if_inet6 or /proc/net/dev or possibly /proc/net/unix.
Thanks,
Brandon Checketts
More information about the Ale
mailing list