Modify the MAC address problem resolution under linux

  • 2020-05-09 19:41:24
  • 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 has changed, but when you type the #service network restart or ifdowneth0 command, the following misinformation will appear:
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 to 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 after restarting, the MAC address is typed back into the prototype. The solution is:
In/etc rc. d/rc. local plus this 3 words
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, when you reload reboot, you don't have to worry about the recovery of MAC, and #service networkrestart doesn't have to make a mistake.

Related articles: