I have a VM which I use as a base each time I need a clean dev environment for testing. That base VM is a regular Ubuntu 20.04 image with additional software installed, which I copy with lxc copy my-base-vm some-test-feature. Network is configured to use macvlan
$ lxc profile show macvlan
config: {}
description: Gives the container an IP address on LAN via DHCP
devices:
eth0:
nictype: macvlan
parent: enp8s0
type: nic
name: macvlan
Every time I copy that VM, the IPv4 address is the same on all machines. IPv6 is different.
Refreshing the DHCP lease manually does give a new IP, but when leaving the VMs overnight, they go back to the same IP. ip addr show a different mac address on all containers.
Trying to reach those containers via IP yields mixed results: things either work for one container, or network can be completely unreliable
If you are talking about the manual renewal I’m running dhclient -r enp5s0; dhclient enp5s0
It should be the router’s DHCP (UDM).
It shows both machines with different mac addresses, but lists them with the same IP. On both machines, the hostname is the same and the uptime is incorrect but the interface is known for being unreliable so hard to know what are router bugs or not
There are plenty of available IPs, which gets attributed when I manually refresh the lease in the instance.
Creating a fresh instance with the same network configuration does not trigger the issue. The new instance gets a different IP. It’s also worth to note that this doesn’t happen with containers, the issue only affects VMs
Adding dhcp-identifier: mac followed by a netplan apply solves the issue. It does renew the DHCP lease with a different IP between all containers
I’ll edit this post in the future if the ip addresses revert back to being the same
It’s the same behavior as asking for a new lease, it does change the IP address for a bit, but a few hours later it reverts back to using the same IP as other VMs
The VMs are supposed to get a new DUID when copied based on the VM’s UUID (which is why I checked they were different), so suggests something has gone wrong their with the DUID regeneration.
I suspect that without the mac stanza in netplan, the VM may rely on /etc/machine-id to derive their DUID. It’d normally be a good idea to clear /etc/machine-id whenever you clone an instance (and if cloud-init is used, I thought it happened automatically through it) as otherwise various bits on the system will use the now duplicated UUID.
The volatile UUID is exposed to the VM through DMI, it’s not exposed to the container.
We could in theory ship a template for /etc/machine-id which aligns it with volatile.uuid but this may also conflict with what some distros may do to setup that file or with manual user actions…
When cloning systems there are a variety of files that need to be reset, regardless of if the system is a container, VM or physical box, so it’s probably best to leave that to the user or to specialized tools like cloud-init. The usual suspects there are:
Yeah in this case its VMs that are having the issue. I thought the DUID was generated from the DMI machine ID, but maybe its written to /etc/machine-id and then not modified on copy.
Right, the DMI UUID is used as initial seed for virtual machines but is then kept constant through /etc/machine-id possibly because of some systems incorrectly exposing a different identifier every boot.
We do already, all distrobuilder images are supposed to have dhcp-identifier set.
I suspect the image used in this case is a cloud image instead, may be worth filing a bug on Launchpad to get the default network-config updated.