Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 eth0

returns this:

Permanent address: 00:00:00:00:00:00


ethtool -e eth0

returns this:

Cannot get EEPROM data: Operation not supported

Network Adapter has following info:

  • driver: ucc_geth
  • version: 1.1
  • firmware-version: N/A
  • bus-info: QUICC ENGINE

Linux kernel version is:

Question 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?

share|improve this question
up vote 5 down vote accepted

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.  */
share|improve this answer
No i do not trust. When mac address is spoofed with ifconfig eth0 hw ether, ifconfig gives the spoofed one not the original one. – Kerim Oguzcan Yenidunya Sep 5 '13 at 13:21
@KerimOguzcanYenidunya then you do have a bit of sub-ioctl programming ahead of you; see my additions above. – msw Sep 5 '13 at 13:55

If you trust the system administrator, then the MAC address from ifconfig will not be spoofed, because by definition you trust the system administrator not to spoof it.

If you do not trust the system administrator, you have no way to know the MAC address of the machine. The machine could be virtual. It could have no network interface. You have no way to know. Even if you find a system call that supposedly does what you want, the sysadmin can choose to run your program in such a way that this system call returns a different result.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.