Welcome to the Linux Foundation Forum!

MAC address in Linux

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

Comments

  • mfillpot
    mfillpot Posts: 2,177
    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)
    
  • Thank you... :-)

Categories

Upcoming Training