nikdoof.com

/posts/ 2024/dhcp6-errors-with-netplan

DHCP6 errors With Netplan and systemd-network on Ubuntu 22.04

Jul 20, 2024

#linux#systemd#ubuntu

I’m currently in the process of improving the build process for some VMware templates, and as part of that, I have to make sure that a sizeable list of security requirements gets ticked off. One of the issues that had been previously identified is that our Ubuntu 22.04 templates all had the same machine-id file. This seems to be related to the template keeping the value configured due to how the combination of install and cloud-init is ran on the template. I updated the image to nuke /etc/machine-id after the template build was complete under some idea that systemd would regenerate it on boot.

As it turns out, different distros respond in different ways to a missing machine-id, some regenerate it as part of the boot, others just ignore it. Ubuntu 22.04 is in the ignore camp. I’m not sure if this is due to the systemd-firstboot function coming in at a later version of systemd or not, but this tripped me up for a while and caused some issues I wasn’t expecting.

Netplan is Ubuntu’s default network configuration manager, an abstraction tool that allows for YAML network configuration to be defined and then rendered out to numerous network interface management tools, e.g. systemd-networkd, NetworkManager, or old-school interface files. VMware’s guest customization works well with Netplan and configures a YAML file with all the network interface configurations you provide, we’ve had this functionality running for years and never had an issue.

After the adjustments to the build, we encountered this error on a fresh VM clone:

Jul 19 10:35:42 testhost1 systemd-networkd[1560]: ens224: DHCP6 CLIENT: Failed to set identifier: No such file or directory
Jul 19 10:35:42 testhost1 systemd-networkd[1560]: ens224: Failed
Jul 19 10:35:42 testhost1 systemd-networkd[1560]: ens192: DHCP6 CLIENT: Failed to set identifier: No such file or directory
Jul 19 10:35:42 testhost1 systemd-networkd[1560]: ens192: Failed

The network interfaces were not coming up at all, and the DHCP6 client was complaining of a missing file. We don’t have IPv6 internally yet, and the interface was set to not use DHCP6 or any sort of discovery for the address, the only option left switched on was IPv6 Link-Local address generation. For some reason, even having this setting on, starts DHCP6 for the interface, and it requires a correct /etc/machine-id! I’m guessing that because DHCP6 failed at this early step it was returning a non-zero exit code and killing the rest of the process for configuring the interface.

Resolving this issue was simple: ensure that /etc/machine-id has been created and generated by running systemd-machine-id-setup.