Modify the MAC address solution under linux

  • 2020-05-06 12:08:38
  • OfStack

In linux, modify the MAC address
# ifdown eth0
# ifconfig eth0 hw ether 12:34:56:78:90:12
(the modified MAC address is different from the original address)
ifup eth0 (modified successfully)
The MAC address changes, but when you type the #service network restart or ifdowneth0 command, the following error message appears:
Device eth0 has MAC address 12:34:56:78:90:12, instead ofconfigured address 00:0C:29:CA:B5:7D. Ignoring.

Therefore, it is impossible to change the IP address and other relevant information by modifying the file /etc/sysconfig/ network-scripts/ifcfg-eth0, because servicenetwork restart cannot take effect. However, the IP address can be changed temporarily with ifconfig eth0, and the prototype can be restarted.
Now solve
"Device eth0 has MAC address 12:34:56:78:90-12, instead ofconfigured address 00:0 C: 29: CA: B5:7 D. Ignoring." question:
The reason for this problem is the configuration file: / etc/sysconfig/network - scripts/ifcfg - eth0 inside MACADDR = 00:0 C: 29: CA: B5:7 and 12:34:56 D address: 78-90:12 different, can be MACADDR = 00:0 C: 29: CA: B5:7 D modified to 12:34:56:78-90:12, the error is eliminated, You can use #servicenetwork restart, but when you restart, the MAC address goes back to the prototype. The solution is
In/etc rc. d/rc. Plus the three other
local ifconfig eth0 down
ifconfig eth0 hwether 12:34:56:78:90:12
ifconfig eth0 up
At the same time will also will/etc/sysconfig/network - scripts/ifcfg - eth0 inside MACADDR = 00:0 C: 29: CA: B5:7 to 12:34:56 D address: 78-90:12
This way, after re-reboot, there is no fear that MAC will be restored, and #service networkrestart will be free of errors.

Related articles: