Network considerations when recreating VMs (reusing block storage)

If you reconnect the existing block storage (disk) to a new VM without deleting it, the network configuration (such as cloud-init) from the previous VM may cause mismatches with the NIC information of the new VM, preventing network connection.

Common cases where this happens

  • Reconnecting (detach → attach) block storage used by an existing VM to a new VM without deleting it
  • During the creation of a VM, creating multiple network interfaces and then deleting/modifying them
    such as attaching a public IP to a different interface and then changing it, which alters NIC configuration
  • As a result, the new VM has different NIC names/sequence, but the disk retains previous NIC settings

How to fix

The commands below do not delete data, only reset the cloud-init settings stored on the disk.

sudo cloud-init clean
sudo reboot