[TriLUG] reliably get network devices

Steven Blanchard sgblanch at gmail.com
Tue Jun 24 12:44:01 EDT 2008


Would something like below work?

$ for dev in /sys/class/net/*; do echo $(basename $dev)=$(cat $dev/address);
done
eth0=00:50:04:XX:XX:XX
eth1=00:50:2c:XX:XX:XX
eth2=00:11:06:00:00:00:0b:ae
lo=00:00:00:00:00:00
sit0=00:00:00:00

~Steven

On Tue, Jun 24, 2008 at 10:48:03AM -0400, Kevin Hunter wrote:
> At 8:48a -0400 on Tue, 24 Jun 2008, Brian McCullough wrote:
> > On Tue, Jun 24, 2008 at 08:24:22AM -0400, Reginald Reed wrote:
> >> I'm curious as to why you wouldn't want to use MAC addresses.  I
> >> combination of the MAC + ifconfig output would be pretty good mapping
> >> of physical to logical.  Since, in most instances, the MAC address of
> >> a NIC wouldn't change, you could easily determine the mapping to ethX
> >> on any boot.
> >>
> >> What am I missing?
> > 
> > I _think_ he's looking for something that he can use to walk up to a
> > completely unknown machine and just automatically "know" what the
> > network devices are.
> 
> Yeap, that's what I want.  Thanks for clarifying, Brian.  I've gotten a
> couple of leads (from this thread) I didn't have before, so I'll check
> those out and get back to the list.  I'm sure I'll be able to better
> describe it after I solve my issue.  :-p
> 
> Kevin
> -- 
> TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG FAQ  : http://www.trilug.org/wiki/Frequently_Asked_Questions



More information about the TriLUG mailing list