RHEL Linux VMware migration eth0 eth1 problems…

I’ve recently had an incident where a Red Hat Enterprise Linux server that had been migrated between two VMware clusters (in this case dev to live) had no network connectivity after the migration.  The server had lost eth0 and had gained an unconfigured eth1 instead.  After a little bit of research I found that this was because the UUID and the MAC address had changed on the virtual hardware making the ifcfg-eth0 configuration file invalid

The fix was fairly simple – remove the UUID from ifcfg-eth0, delete the udev rules for the the network card, correct the MAC address and restart the network service.

I wrote this simple script for others to use:


# Backup all files first
mkdir nic_change_backup
cp /etc/sysconfig/network-scripts/ifcfg-eth0 nic_change_backup
cp /etc/udev/rules.d/70-persistent-net.rules nic_change_backup
tar jcpvf nic_change_backup.tar.bz2 nic_change_backup
rm -rf nic_change_backup

# Remove the udev rule
# They are re-created on boot up
rm -f /etc/udev/rules.d/70-persistent-net.rules

# Fix the eth0 file
# This involves removing the UUID and
# updating the HWADDR with the MAC
# address of the new card.
grep -v UUID /etc/sysconfig/network-scripts/ifcfg-eth0 | sed '/HWADDR/c\'$(echo "HWADDR:$(echo "$(ip addr | grep ether | cut -d\  -f 6)" | tr '[:lower:]' '[:upper:]')") > /etc/sysconfig/network-scripts/ifcfg-eth0

# Restart networking, or in this case the server
shutdown -r now

Leave a Reply