It is well know that through the ip
and ifconfig
commands it is possible to change a MAC address temporarily, meaning the change will not persist across host reboots.
But what if you would like to change your MAC address in a more permanent fashion? Is there a way to, through software, permanently change your network interface card's MAC address?
It turns out the answer is yes, and the tool to do so is called ethtool
.
Ethtool comes pre-installed on many stock distributions of Linux, but can also be installed from your package manager of choice if necessary.
It is possible to read and write to the network interface card EEPROM using the ethtool -e $DEVICE_NAME
(read) and ethtool -E $DEVICE_NAME < $EEPROM_BACKUP.bin
(write).
If you would like more granular control over the EEPROM contents, the -E
argument has several sub-arguments, of the form
$ ethtool -E eth0 magic=$MAGIC_NUMBER offset=0x0 length=0x1 value=0xff
Here $MAGIC_NUMBER
is dependent on the NIC firmware. For example, the e1000
line of NICs uses vendor_id
and the device_id
(both of which can be retrieved via lspci -n
)
Source: https://github.com/torvalds/linux/blob/master/drivers/net/ethernet/intel/e1000/e1000_ethtool.c#L480
When you update the NIC EEPROM in this manner, the MAC address will persist across host reboots.
NB: Some NICs do not support EEPROM write. Use ethtool -i
to see NIC capabilities
For Example, VMWARE does not allow write access to the virtual NIC
hello sir i tried this tool 3 or 4 times but til im not successful for changing values in eeprom of router , may be i couldn't understood proper procedure ..whenever i use this method it detect internal laptop(wireless card) mac address , but i want to change the router mac address permanently in EEPROM , im searching on this topic from last many days please help if you can , thanks in advance