Best way to get the MAC of eth0?

It's at /sys/class/net/eth0/address (or more precisely /sys/devices/pciXXXX:XX/XXXX/net/eth0/address where the XXX is your PCI bus ID, but this varies between systems).

(Incidentally, I found this with find /sys -name eth0 and looking at the files in the directories identified.)


It's also available via ifconfig:

kce@thinkpad:~$ /sbin/ifconfig eth0 |grep HWaddr
eth0      Link encap:Ethernet  HWaddr 00:1e:37:cc:ce:cc  

Or if you want just the MAC address:

kce@thinkpad:~$ /sbin/ifconfig eth0 |awk '/HWaddr/{print $5}'
00:1e:37:cc:ce:cc

if you can install moreutils package, there is a ifdata tool. Description says:

ifdata: get network interface info without parsing ifconfig output

Here's an example:

me@box:~$ ifdata -ph eth0
00:21:86:61:35:44