MAC address in Linux

Link to this post 28 Apr 10

Hi, have problem with MAC address! I am change MAC address ('ifconfig eth0 hw ether ') after I want to do that was. Earlier, I can get my MAC address after reboot. Please tell me where is file with MAC address. I find in /proc but there I find nothing, /sys is the same. What do I do??? P.S. linux 2.6.28

Link to this post 28 Apr 10

I have been really scouring /proc and /sys to find an answer for you, I have found the location(s) in /sys/ where it is stored, but the address changes in those items when you change it via ifconfig.

The location of the file is /sys/class/net/{interface}/address

Since it appears that it cannot be retrieved once changed (without a reboot) you can write a script to store the contents of the file listed above and then make a reference to it when you want to change the value back.

#Store the existing ethernet address
cat /sys/class/net/eth0/address>>~/HW_add.txt

#restore the MAC address from the file
ifconfig eth0 hw ether $(cat ~/HW_add.txt)

Link to this post 28 Apr 10

Thank you... :-)

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board