English
Troubleshooting duplicate NIC UUID issues after cloning a CentOS virtual machine

Problem Background
After cloning a CentOS virtual machine in a vSphere environment, the NIC UUIDs of the source virtual machine and the cloned machine will be exactly the same, causing network services to be unable to correctly manage network connections.
Solution: Use uuidgen to generate a new UUID
This paper adopts traditional network services Manage network cards (rather than NetworkManager), through systemctl restart network Restart the network.
Operating steps
1. Generate a new UUID
bash
uuidgenOutput example:
40979f2a-ca4b-4105-8b11-048ea46ab5422. Edit the network interface configuration file
bash
vim /etc/sysconfig/network-scripts/ifcfg-ens1923. Modify UUID value
the ... in the configuration file UUID Replace the line with the newly generated UUID:
ini
UUID="40979f2a-ca4b-4105-8b11-048ea46ab542"4. Restart the network service
bash
systemctl restart network5. Verify that the UUID has been updated
bash
cat /etc/sysconfig/network-scripts/ifcfg-ens192 | grep UUIDOutput example:
UUID="40979f2a-ca4b-4105-8b11-048ea46ab542"Complete Command Quick Reference
bash
# Complete all operations with one command (replace ens192 with the actual network interface name)
NEW_UUID=$(uuidgen) && \
sed -i "s/^UUID=.*/UUID=\"$NEW_UUID\"/" /etc/sysconfig/network-scripts/ifcfg-ens192 && \
systemctl restart network && \
echo "UUID updated to: $NEW_UUID" && \
nmcli connection showVerify that the network is normal
bash
# View IP address
ip addr show ens192
# Test network connectivity
ping -c 4 8.8.8.8Precautions
The NIC name is not necessarily
ens192, or it may also beeth0,ens33etc., please modify according to the actual situationAfter modifying the UUID, there is no need to restart the virtual machine; restarting the network service will take effect.
Virtual machine NIC UUIDs within the same LAN must be unique
Use
systemctl restart networkThe prerequisite is that the system has enabled the traditional network service and disabled NetworkManager.
Switch to network service (optional)
If the system uses NetworkManager by default, you can switch to the traditional network service:
bash
# Stop and disable NetworkManager
systemctl stop NetworkManager
systemctl disable NetworkManager
# Enable network service
systemctl enable network
systemctl start networkPreventive measures (template machine configuration)
Execute before converting the virtual machine to a template:
bash
# Delete the UUID so that it is automatically generated when the cloned machine starts for the first time.
sed -i '/^UUID=/d' /etc/sysconfig/network-scripts/ifcfg-ens192This way, each new machine cloned from the template will automatically generate a unique UUID, with no manual handling required.