How can I determine the MAC address for a NIC in CentOS without using ifconfig?
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.
for CentOS 7:
ip a
in my box, the MAC comes after 'link/ether'
ex:
link/ether cc:10:ee:5f:d8:aa
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