Updating MAC Addresses (CentOS/RHEL)

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.

Instructions:

  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/pci/drivers/e1000/0000:00:03.0
    /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

 

    • Related Articles

    • Checking IP address configuration

      Q: How can I check the IP address that IPMI is using? A: The motherboard will list the IP address in the BIOS, usually under IPMI > Set LAN Configuration. By default we leave DHCP turned off and set 0.0.0.0 as the static IP before shipping, for ...
    • Physical port layout

      Q: Which physical network port does IPMI operate over? A: IPMI will function over one of two ports on the motherboard integrated NIC, and utilizes a failover option to determine which interface it will use. The first port is the dedicated IPMI port, ...
    • Changing NIC failover mode

      Log into the IPMI web interface by entering the IP address into the URL of a web browser on a client system. Go to Configuration > Network, and scroll down to the drop-down list for LAN Interface, or Default Interfaces. The default setting is Fail ...
    • Install the Latest Stable Kernel on CentOS 6/7

      Source: http://www.makeuseof.com/tag/update-linux-kernel-improved-system-performance/ CHECK LATER: http://www.makeuseof.com/tag/5-reasons-update-kernel-linux/   --- DRAFT 8/30/16 - Adam Why update to latest stable kernel? Performance improvements new ...
    • Motherboard model and serial

      Q: How do I determine my motherboard model and serial numbers? A: This information is written into DMI into the motherboard. To access it, simply use dmidecode, available on most UNIX and Linux operating systems by default, and available as a ...