[TriLUG] reliably get network devices

Kevin Hunter hunteke at earlham.edu
Tue Jun 24 07:00:35 EDT 2008


At 6:28a -0400 on Tue, 24 Jun 2008, Carl Crider wrote:
> Don't know if this is what you are looking for. Maybe I'm just confused by
> the question.

Heh, then perhaps I'm not asking the question I think I'm asking!

> ifconfig -a
> 
> ifconfig | less

This is the next step in what I want to do.  The problem is that this
will return what the OS has, but what the OS has (or provides) does not
appear to be a guaranteed or set mapping.  That is eth0 might be one NIC
card on one boot, then the other on a different boot.  I'm looking for a
consistent mapping.  I could use the MAC addresses, but then I'm back to
individually identifying cards, which is not an option.

I wonder if the underlying problem is that the OS uses the
non-deterministic "order in which they respond to a probe" to be the
order of the NICs, in which case I may be up a creek.  I hope not.

So, how do I dynamically (programmatically) probe what NICs are
available and get a consistent mapping?

Thanks,

Kevin



More information about the TriLUG mailing list