finding all configured IP addresses in /proc

Matt Graham danceswithcrows at usa.net
Wed Apr 28 08:01:26 MST 2010


From: Alex Dean <alex at crackpot.org>
> From time to time, I've poked around in /proc/net trying to find a  
> list of all the IP addresses currently configured on a linux machine.   
> I usually use ifconfig for this purpose, but I'm guessing this data is  
> in /proc/net somewhere as well.  I just can't find it.  Can anyone  
> enlighten me?

IIRC, ifconfig gets the IP info from all network interfaces on the system
differently.  It first does an ioctl() with SIOCGIFCONF to get a list of
interfaces, then calls ioctl() with SIOCGIFADDR on each interface.  It doesn't
read anything in /proc/net/ .  Why it does things this way, I don't
know--that's just what I remember from messing with this stuff at a low level
a few years back.  I have a small and simple C program that does all this
stuff, but I can't remember where I left it.  Probably on my laptop at home.

-- 
Matt G / Dances With Crows
The Crow202 Blog:  http://crow202.org/wordpress/
There is no Darkness in Eternity/But only Light too dim for us to see




More information about the PLUG-discuss mailing list