I need to read permanent (burned-in) MAC address of network adapter. Since MAC address can be easily spoofed, I need to read the real one which is written on EEPROM. I need to do it using C++ on Linux.I tried using ethtool which is quite good and works fine. However on some systems it does not work as intented.ethtool -P eth0returns this:Permanent address: 00:00:00:00:00:00andethtool -e eth0returns this:Cannot get EEPROM data: Operation not supportedNetwork Adapter has following info:driver: ucc_gethversion: 1.1firmware-version: N/Abus-info: QUICC ENGINELinux kernel version is: 2.6.32.13Question is: Can i fix this issue with any update(driver, kernel etc)?Additionally, I make the same ethtool calls with ioctl function in C++. Is there any way to fix this inside the code? Or is there any other way to get the permanent MAC address from EEPROM?
ethtool get permanent MAC address returns all 0's
linux;networking;ethernet;c++;mac address
If you trust the local machine not to be spoofing, both ifconfig and ip addr will give you the MAC address of the hardware.If you don't trust the local machine, neither ethtool, ifconfig, nor ip is going to provide you the information you need. Because there are very legitimate reasons for MAC spoofing (for example, hot-fail on ethercards) all the drivers report only the currently virtual MAC address because if you need to spoof the address it wouldn't do well for some of the tools to report the firmware address and others to report the soft address. No ioctl can or should give you the hard-address.To get the hard-address requires reading the device registers directly and is thus completely device specific. A quick look through the ucc_geth.c driver seems to show that MAC address reassignment is supported by the chip itself (which makes sense as it needs to be able to pluck packets sent to its soft address off the ether). This means that you need to be very deliberate to ensure you are getting the hard address for which the driver liberally says:/* For more details see the hardware spec.  */