Correcting the eth0 MAC Address in RHEL or CentOS

Cloning machines in VMWare is really straightforward thing. However once you do clone a machine, you’ll be left with new MAC addresses for the network cards. In a typical scenario the cloned RHEL or CentOS machine will boot up without the local network interface. You’ll typically see the following during boot.

Bringing up interface eth0: Device eth0 has different MAC address than expected, ignoring.

The reason for this is that

/etc/sysconfig/network-scripts/ifcfg-eth0

contains a variable called “HWADDR=”. Do the following to add the appropriate MAC address and restore networking functionality.

  • As the root user (or a user with appropriate permissions)
  • Type “ifconfig -a”
  • From the displayed information, find eth0 (this is the default first Ethernet adapter)
  • Locate the number next to the HWaddr. This is your MAC address

A typical output would be as follows.

eth0      Link encap:Ethernet  HWaddr 00:1B:21:1F:66:88
          inet addr:192.168.0.5  Bcast:192.168.0.255  Mask:255.255.255.0
... the additional output has been removed...

Now you edit

/etc/sysconfig/network-scripts/ifcfg-eth0

and modify the “HWADDR=” variable to include your MAC address. E.g.

HWADDR=00:1B:21:1F:66:88

Save the file. At this point you run

# service network restart

as root from the command prompt. You’ve now restored networking.

// CrashMAG

2 thoughts on “Correcting the eth0 MAC Address in RHEL or CentOS”

  1. Maybe not relevant to your situation, but in my case it didn’t help to modify the HWADDR or to change the mac address manually in the vSphere client (running Esxi/vCenter 4.1).

    My solution was to first set the VM’s nic to manual, create a new mac addr, then remove VMWare tools, reboot, install VMWare tools again, reboot.

  2. After I installed Centos, I did not see information NIC, I just saw the Lo card only. How can I see the information of physical NIC?

    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

*