Updating MAC Addresses (CentOS/RHEL)

If your system's motherboard has recently been replaced, you may encounter network failures due to the new motherboard using different MAC addresses. Modern Linux distributions such as CentOS and Red Hat will typically auto-populate udev rules and network configurations, which saves time on initial deployment, but these will not automatically update if the MAC addresses are different on the new motherboard. For now, you will have to manually update the MAC addresses after a motherboard replacement.


  1. Determine which PCI IDs are assigned to your Ethernet device(s).
    # lspci -v | grep Ethernet
    00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)
  2. Make note of the PCI device ID given at the beginning of the line in the results. In this case there is only one Ethernet device, so we will search for the driver assigned ID 00:03.0.
    # find /sys | grep drivers.*00:03
    /sys/bus/pnp/drivers/i8042 aux/00:03
  3. In this case the find command returned multiple results, but the second result pertains to a plug n' play driver, so we can ignore it. The directory that contains the entry for ID 00:03.0 is named "e1000", so later on we will be loading and unloading the e1000 kernel module to reset the driver.
  4. Create backups of your existing udev network configuration file, as well as the corresponding network scripts for each interface you want to change. In this example we will only reconfigure eth0, so repeat the second command for eth1, eth2, eth3, etc.
    # cp /etc/udev/rules.d/70-persistent-net.rules /etc/udev/rules.d/70-persistent-net.rules.backup
    # cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.backup
  5. Scan the udev configuration file for the entry related to the Ethernet device you want to change, and repeat for additional devices. The MAC address will be listed next to ATTR{address}==.
    # grep eth0 /etc/udev/rules.d/70-persistent-net.rules
    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:9a:f7:36", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
  6. To update the entry, you can either manually edit with a text editor such as vim or nano, or use sed to replace the string in a single command. Note that in the udev rules the alphabetical characters for MAC addresses are lower case, so make sure that your replacement MAC also uses lower case letters. Here is the syntax with sed:
    # sed -i 's/oldmac/newmac/g' /etc/udev/rules.d/70-persistent-net.rules
    In this example, we'll change the last two digits from 36 to 20:
    # sed -i 's/08:00:27:9a:f7:36/08:00:27:9a:f7:20/g' /etc/udev/rules.d/70-persistent-net.rules
  7. Update the MAC address used in the network configuration script as well, using the same method in the previous step. Note that the network scripts use upper case letters in the MAC addresses. Repeat this step for additional devices such as eth1, eth2, eth3, etc.
    # sed -i 's/08:00:27:9A:F7:36/08:00:27:9A:F7:20/g' /etc/sysconfig/network-scripts/ifcfg-eth0
  8. After updating the configuration files, unload and reload the kernel module.
    # modprobe -r e1000
    # modprobe e1000
  9. Reset the network device with ifdown and ifup, and repeat for each additional device.
    # ifdown eth0
    # ifup eth0


Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Powered by Zendesk