Skip to content

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

CentOS network card configuration diagram

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
uuidgen

Output example:

40979f2a-ca4b-4105-8b11-048ea46ab542

2. Edit the network interface configuration file ​

bash
vim /etc/sysconfig/network-scripts/ifcfg-ens192

3. 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 network

5. Verify that the UUID has been updated ​

bash
cat /etc/sysconfig/network-scripts/ifcfg-ens192 | grep UUID

Output 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 show

Verify that the network is normal ​

bash
# View IP address
ip addr show ens192

# Test network connectivity
ping -c 4 8.8.8.8

Precautions ​

  • The NIC name is not necessarily ens192, or it may also be eth0,ens33 etc., please modify according to the actual situation

  • After 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 network The 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 network

Preventive 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-ens192

This way, each new machine cloned from the template will automatically generate a unique UUID, with no manual handling required.

Last updated on11/07/2026, 02:16 PM
@fishfinal | @fishfinals | [email protected]