I am running a few VM machines on my XCP-ng (Xen) Hypervisor.
I created a template. With that template I create new VMs running RockyLinux9.2.
Basically the VM in the template gets cloned so to have unique values on some calculated addresses I change the following on the new VM (with a cloud-init script).
- change the hostname
etc/machine-idand recreate it with
am I missing anything else?
I did notice that the uuid of the network connection is the same. Is that a problem? And if yes, what is the right way of changing it?
Every time if I restore a snapshot or the VM is moved to an other host in the same pool or the vm is stopped and started again. Either XCP-ng and/or RockyLinux NetworkManager seems to generate a new MAC Address for the VM. This does not work well with my DHCP-Server where I give static leases to some of the vms based on the MAC address.
I would like to control ips with my DHCP-Server so I do not want to fall back to setup static IPs.
I did read the documentaton for NetworkManager and think that there is a way, I just find the description very confusing and I did not find any examples.
Thinks I tried and could think of.
- The DHCP-Server links static IPs only to the hostname → My current workaround but I am not too happy with it since the hostname is not my fist choice.
- Make the MAC address static → I already tried to set a static MAC address. Basically, this is working for every DHCP Lease, except the first one, also the MAC address XCP-ng is showing for that VM is different than the I set manually. However, the DHCP server does see the manually set address, it is just super confusing that the managing interface of XCP-ng is showing a different one, and also the reason that XCP-ng is the main culprit for this MAC address change fiasco and the reason why this solution is also not optimal.
- Use the DUID to pin the IP to a VM in the DHCP server → This would be my choice, but I did run into a few problems.
a) I did not find and/or understand the settings to keep DUID unique for every machine and network device (currently there is only one, maybe in the future there are VMs with more than one network device), even with changing MAC addresses. As a bonus it would be fine if the private Ipv6 address would not be changing too when the MAC addresses change. I did find some hints with static-id but since I do only want the DUID to be static this seems a bit much also I did not get it to work properly. Configuration example would be highly welcome.
b) I run a Firewall machine, and multiple windows machines as well as a pdu and an managed switch. All of these devices do publish the DUID and I see them when looking at the DHCP leases on my DHCP-server. However, for every RockyLinux9.2 installation the DUID is missing. My guess is that NetworkManager by default is not publishing the DUID when making an DHCP ip request call. What settings are necessary to publish the DUID so that I can address them on my DHCP-server?