We're using a ubuntu-18.04
template on a virtualization environment. Therefore, before creating the template, we always empty the /etc/machine-id
file so it's recreated upon the first boot.
The problem is that if several ubuntu-18-based VMs are started at once, systemd-machine-id-setup
will generate the same ID for all of them, resulting in IP duplication. I checked these servers and they all have the same content in the /etc/machine-id
file.
If machines are powered-on spaced in time, different IPs are assigned, thus I assume systemd-machine-id-setup
is generated based on current time (possibly). This isn't acceptable for us because of the problem in the image above.
Is there a way to make the OS generate the /etc/machine-id
on boot based on an alternative binary?
--- UPDATE 1 ---
On @GeraldSchneider's tip, I switched back from netplan to ifdownup and the IPs stopped duplicating, so definitely this is a netplan issue.
Even if this could solve the problem, I'm curious if there's a way to set an alternative way to generate the /etc/machine-id
file so no duplications happen using netplan.
/etc/machine-id
to see if it is actually the same on each system? The machine ID file is not normally used to obtain an IP address. How are you assigning IP addresses?machine-id
file has exactly the same value on the machines that are powered-on within the same time lapse. If machines are powered-on on different time lapses, the file content varies. IP addresses are assigned via DHCP. Actually, this file seems to be used to acquire IP addresses: jaylacroix.com/…MAC
instead ofmachine-id
usingdhcp-identifier: mac
, it seems this is a common issue with netplan and the changed DUID.