Header Shadow Image


How to find the MAC address of an ethernet or wireless card.

To find the MAC address of an ethernet or wireless card is generally straight forward for straight forward configurations.  The MAC address is a unique identifier for every NIC (Network Interface Card) that uniquely identifies that card amongst all others.

There's several commands that can be used for this depending on your network configuration and setup.  The basic command to use for this is ifconfig (Equivalent of netstat -ie):

# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 1C:6F:65:3F:FC:14 
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:339061 errors:0 dropped:0 overruns:0 frame:0
          TX packets:183764 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:82692563 (78.8 MiB)  TX bytes:121295829 (115.6 MiB)
          Interrupt:32 Base address:0×4000

However once the network configuration becomes a bit more complex, this just won't do:

For example, in a bonding configuration, ifconfig will list the same MAC address for all the cards:

# ifconfig

bond0     Link encap:Ethernet  HWaddr 1C:6F:65:3F:FC:14 
          inet addr:192.168.7.10  Bcast:192.168.1.255  Mask:255.255.254.0
          inet6 addr: fe80::1e6f:65ff:fe3f:fc14/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:345632 errors:0 dropped:0 overruns:0 frame:0
          TX packets:186780 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:85617681 (81.6 MiB)  TX bytes:122381805 (116.7 MiB)

eth0      Link encap:Ethernet  HWaddr 1C:6F:65:3F:FC:14 
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:345632 errors:0 dropped:0 overruns:0 frame:0
          TX packets:186780 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:85617681 (81.6 MiB)  TX bytes:122381805 (116.7 MiB)
          Interrupt:32 Base address:0×4000

eth1      Link encap:Ethernet  HWaddr 1C:6F:65:3F:FC:14 
          UP BROADCAST SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

Unfortunately, even with udevadm the addresses come back looking the same:

# udevadm info -a -p /sys/class/net/eth0|grep address
    ATTR{address}=="1c:6f:65:3f:fc:14"
# udevadm info -a -p /sys/class/net/eth1|grep address
    ATTR{address}=="1c:6f:65:3f:fc:14"
# udevadm info -a -p /sys/class/net/wlan0|grep address
    ATTR{address}=="00:25:86:f1:65:d0"
# udevadm info -a -p /sys/class/net/bond0|grep address
    ATTR{address}=="1c:6f:65:3f:fc:14"

An alternate command is:

# udevadm info –attribute-walk –path /sys/class/net/eth0

And after a bonding configuration, wlan0 will show the MAC of bond0.  In cases like this, we can use the bond0 interface to get the real MAC address for the device:

# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 1c:6f:65:3f:fc:14
Slave queue ID: 0

Slave Interface: eth1
MII Status: down
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 90:e2:ba:1a:08:28
Slave queue ID: 0
#

Any active devices in a bonding configuration will show the MAC of the primary device but using the above command will display the real / permanent MAC address of the participating NIC's.

Cheers,
TK

One Response to “How to find the MAC address of an ethernet or wireless card.”

  1. [...] Find a MAC Address [...]

Leave a Reply

 


     
  Copyright © 2003 - 2013 Tom Kacperski (microdevsys.com). All rights reserved.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License