Comment 3 for bug 1328285

Revision history for this message
Steve Langasek (vorlon) wrote :

<slangasek> stgraber: do you know a proper way to programmatically get a list of all network interfaces on a system, including those that are currently down? http://linux.die.net/man/7/netdevice documents that SIOCGIFCONF doesn't include down interfaces, and recommends /proc/net/dev instead
<stgraber> slangasek: I usually iterate through /sys/class/net which works fine if you just want a list or want physical interface related kind of information. If you need to query the interface configuration, then you need getifaddrs and it's a whole other kind of worm (also, some most IPv6 info is also in /proc, but ipv4 isn't... yay for consistency)
<slangasek> stgraber: context is whoopsie trying to get a mac address to use as a system identifier; this shouldn't be dependent on network interfaces being up
<stgraber> slangasek: /sys/class/net/*/address will get you that
<stgraber> slangasek: if you want to make sure you've got an ethernet device (and therefore a MAC), check that /type == 1 too