DHCP Client ID conflicts when running multiple instances
Created by: davidscaife
Note: I'm using the archlinux/archlinux box with the libvirt provider. In theory this issue should affect other providers, but I have not tested. (It may also be contingent on DHCP server configuration/behaviour which will probably differ between providers.)
vagrant up a single box, everything is fine. If I
vagrant up a second box while the first is running, I can no longer access the first box, and if I have a live
vagrant ssh session, the session closes.
Even though the virtual network devices are getting different MAC addresses, the boxes are nonetheless passing the same client-id to the DHCP service. This is visible by watching the contents of
/var/lib/libvirt/dnsmasq/*.status. Because both boxes are exposing the same client-id, the DHCP service gives them both the same IP, causing a conflict.
It seems the archlinux boxes use systemd-networkd for network configuration with DHCP. By default, systemd-networkd will use the machine-id as an assumed unique identifier for the local machine, and use this (hashed) as the DHCP client-id. However, all "archlinux/archlinux" boxes have the same machine-id as it is created during the build process, and the build process does not delete it.
That's the root of the problem, so I would suggest deleting
/etc/machine-id as one of the final steps in the build process. This would mean new machines would generate their own unique machine-id upon first boot, which will resolve the above DHCP conflicts.