How can I determine the MAC address for a NIC in CentOS without using ifconfig?

CentOS 5.5

One of my CenTOS systems recently booted with the following error:

"Bringing up interface eth0: Device eth0 has difference MAC address than expected. ignoring."

When I run ifconfig -a there's no entry for eth0 and I'm reasonably certain that the static HWADDR entry in /etc/sysconfig/network-scripts/ifcfg-eth0 is incorrect.

Are there alternate ways for definitively determining what the correct MAC addresses are via the command-line? I was wondering if perhaps lspci could help? I don't have hwinfo available.


Solution 1:

if there is no entry in ifconfig -a... that means the device is not detected in the machine... (either due to missing driver support or bad/mis-identified hardware) check dmesg to confirm that "eth0" is detected by the system at all. You can also lspci to list all devices attached to the system... and look for unknown devices and/or your ethernet controller.

Solution 2:

for CentOS 7:

ip a

in my box, the MAC comes after 'link/ether'

ex:

link/ether cc:10:ee:5f:d8:aa

Solution 3:

You can use:

For all interfaces:

cat /sys/class/net/*/address

For ethernet0 interface:

cat /sys/class/net/eth0/address

Extracted from: http://www.sysadmit.com/2018/01/linux-saber-direccion-mac.html