[RndTbl] determine IP address in linux

Adam Thompson athompso at athompso.net
Mon Mar 25 11:55:41 CDT 2013


On 2013-03-24 18:06, Trevor Cordes wrote:
>> can't do it from shell.  Use
>> AF_NETLINK, which is what ip(8) does internally.  Bad design, 
>> IMHO...
>
> So if I whipped up a little C proggie I could rely on it not to
> change?  Hmm, maybe that's the way to go, but then I have to worry
> about keeping compiled binaries up to date :-(

Well, if it's a statically-linked binary (use uLibc if necessary to 
keep the size reasonable) and you follow the LSB guidelines, it should 
remain portable pretty much forever.  At least until AF_NETLINK is 
deprecated, which I would expect to be a very very very long time from 
now.
You still have to take into account multi-homed systems, but at least 
you can get the device names out of /proc/net/dev or 'netstat -i'.
-Adam



More information about the Roundtable mailing list