Traduisez - Übersetzen - Traduzca - Traduza - Tradurre - Translate

VanLUG Email Archive

Re: Reading an Ethernet card's hardware address?

Rick Franchuk
Fri, 16 Oct 1998 05:09:48 -0700 (PDT)

On Thu, 15 Oct 1998, Dave Michelson wrote:

> Hi, all.
>
> Can anyone point me towards material which explains how one might read the
> hardware addresses of any Ethernet cards installed in a Linux x86 system?
>
> I'm not talking about autoprobing. I'm hoping that a safer, more generic
> method can be employed once the appropriate driver/module has been loaded.
>
> (Looking over the source in /usr/src/linux/drivers/net wasn't too
> illuminating, I'm afraid.)

Hi Dave,

By far and away the easiest way to gather information about operational
interfaces would be by opening /proc/net/arp and scan through it for the IP
address you're interested in. Of course, you make the assumption that the arp
table has been filled for that addr.

Outside of that, Mr. Stevens says (in UNPr2 vol 1 page 429) describes some
ioctl bits that should do the job, and he throws together a little routine
which generates a linked list of interfaces available, along with code to
scoop up MACs on BSD/OS a bit later on... Linux' ip stack is very BSDish, so
you might get lucky with that.

Alternately, pop on to irc.blackdown.org and ask Alan Cox (who frequents
there regularly) or some of the other kernel twitchers if there's a
straightfoward way to handle it under linux.

--
  __________________________________________
 |                                          |
 |  Rick Franchuk  -  TranSpecT Consulting  |
 |_______                            _______|
         \mailto:rickf@transpect.net/
          \_____ICQ_#_4435025______/