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

  • 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.
    1. #Store the existing ethernet address
    2. cat /sys/class/net/eth0/address>>~/HW_add.txt
    1. #restore the MAC address from the file
    2. ifconfig eth0 hw ether $(cat ~/HW_add.txt)
  • Thank you... :-)

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training