6

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.

IP duplication

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.

no duplicated IPs

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.

nKn
  • 111

1 Answers1

2

...I'm curious if there's a way to set an alternative way to generate the /etc/machine-id file...

Per the machine-id manual page,

...Otherwise, the value in /etc/machine-id will be used. If this file is empty or missing, systemd will attempt to use the D-Bus machine ID from /var/lib/dbus/machine-id, the value of the kernel command line option container_uuid, the KVM DMI product_uuid (on KVM systems), and finally a randomly generated UUID.

And also, towards the bottom of the page,

The simple configuration file format of /etc/machine-id originates in the /var/lib/dbus/machine-id file introduced by D-Bus. In fact, this latter file might be a symlink to /etc/machine-id.

Therefore, it is also possible to set the machine-id using dbus-uuidgen, as can be seen in the following answer:

Per the dbus-uuidgen manual page,

If you run dbus-uuidgen with no options it just prints a new uuid made up out of thin air.

oxr463
  • 372