Cloning Customized VM and LXCs: Prepping for Use (MachineID, MAC, etc.)

Sep 1, 2022
276
54
33
40
Hello,

As a preliminary matter, I know that (one of) the correct way(s) to do what I'm about to ask about is to deploy a VM with Cloud-Init and then set it up with an automation tool like Ansible. Mostly I'm posting this because I'm not ready to learn to use Ansible yet, as I'm in the middle of learning several other things (Proxmox firewall config, at the moment), but still want to make sure I'm deploying my cloned guests correctly.

(Without Ansible or something similar, cloud-init doesn't get you a set-up, ready-to-use, fully-configured system, which is what got me thinking about this. I'm trying to figure out the feasibility of pre-configuring a machine and cloning it without any sort of automated deployment tools.)

These are the items I know I'd have to change.
  1. In particular, I use reserved DHCP addresses on my firewall for static IP addresses, so I depend on each guest having a unique MAC address. But apparently just cloning a VM or LXC doesn't automatically change the MAC on existing virtual NICs (preserving them is a reasonable default). So I'd need to either clone them without the NICs, or change the MACs afterwards.
  2. Linux guests each have a machine-id. (See: https://man7.org/linux/man-pages/man5/machine-id.5.html ). Cloning the guest won't alter the machine-id, so I'd have to do that manually as well.
Optional/recommended:
  1. Unique SSH public key. There's a lot of debate on whether you actually need to have a unique public key for each guest, especially in a small home/home office with one human user, but I think you'll end up with more than one as soon as you start using SSH keys to automate things...
  2. Non-root user/non-root user and password. Honestly, if you want to change any of these and plan to deploy any number of guests, I think you have to use cloud-init or something similar.
Questions.
  1. Am I missing anything from the list of required changes to avoid having two VMs step on each other?
  2. If not, do y'all think it would be a useful feature request to add a pair of new options to the guest clone GUI in Proxmox:
    1. [ ] randomize machine-id (for Linux) and
    2. [ ] randomize NIC MAC addresses (with an option to choose which NICs, or all of them)?
 
  • Like
Reactions: Kingneutron
  1. In particular, I use reserved DHCP addresses on my firewall for static IP addresses, so I depend on each guest having a unique MAC address. But apparently just cloning a VM or LXC doesn't automatically change the MAC on existing virtual NICs (preserving them is a reasonable default). So I'd need to either clone them without the NICs, or change the MACs afterwards.
  2. Linux guests each have a machine-id. (See: https://man7.org/linux/man-pages/man5/machine-id.5.html ). Cloning the guest won't alter the machine-id, so I'd have to do that manually as well.
1. There is an option to create new MAC addresses when cloning a VM template.

2. Remove /etc/machine-id as a last step before creating the VM template. A new machine ID will be created at first boot.
 
  • Like
Reactions: Kingneutron

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!