UTM icon indicating copy to clipboard operation
UTM copied to clipboard

Randomize mac address when cloning a VM

Open mvysny opened this issue 10 months ago • 2 comments

Describe the issue
I have one base Linux VM with basic things set up; I tend to clone it and rename it whenever I need to spin up an experimental VM, or a VM per project.

Recently I noticed that when I have a VM running and I start a new one, all TCP/IP connections on the first VM will stop working - they won't close but no data will be transmitted, and will appear frozen.

Just today I realized that all VMs are using shared networking and all have same mac address. When I changed the mac address to a random one, the problem disappeared.

I think the best solution would be: when a VM is cloned and it uses Shared Networking, change the mac address to a random one.

To reproduce:

  1. Create a Linux VM, with Shared networking
  2. Clone it two times, into VM1 and VM2. Observe that all three VMs have the same mac address.
  3. Start VM1 and ssh to some remote server
  4. Start VM2
  5. Observe that the ssh connection in VM1 is dead.

Configuration

  • UTM Version: 4.6.4 (107) from App Store
  • macOS Version: 15.3.1 (24D70)
  • Mac Chip (Intel, M1, ...): M3 Max

mvysny avatar Feb 25 '25 06:02 mvysny

This was done specifically because people complained about network not working after cloning a VM because of the same mac address: https://github.com/utmapp/UTM/issues/2724

I'll take into consideration if shared networking is used or not.

osy avatar Feb 25 '25 18:02 osy

Following.

In VMware/vSphere if you clone a vm, it automatically assigns a new mac address to the cloned vm. It would be nice if UTM did this.

mattboston avatar May 06 '25 20:05 mattboston

I realize that adding an option adds friction, but maybe a checkbox in UTM settings for "regenerate MAC address when cloning" ?

Currently changing the MAC address can break some OS or software activation or device identification; when I clone a VM I usually don't want the MAC to change, because I'm testing something temporarily and want to keep everything else the same.

(Actual snapshots/rollback would solve this issue for my particular usecase, perhaps for others as well).

ideologysec avatar Jul 08 '25 22:07 ideologysec

@ideologysec I would be happy with that solution.

mattboston avatar Jul 09 '25 13:07 mattboston