DHCP lease duration time

Hello,

We have an issue while creating our linux masters with packer (1.10 for now).

The OS get an ip from packer dhcp, but since it doesn’t use it at all times (eg: reboot), when we compile multiple masters at the same time, another compilation sometimes gets the same ip assigned.

Is there a way to an ip to be assigned for a defined time, even if the OS reboots or isn’t always up ?

Thanks

It seems my issue is more caused by the fact that qemu creates all the vm with the same network card DUID, and the same mac address :

2025/08/04 15:55:07 packer-plugin-qemu_v1.1.1_x5.0_linux_amd64 plugin: 2025/08/04 15:55:07 Qemu stdout: DUID 00:03:00:01:52:54:00:12:34:56
2025/08/04 15:55:07 packer-plugin-qemu_v1.1.1_x5.0_linux_amd64 plugin: 2025/08/04 15:55:07 Qemu stdout: eth0: IAID 00:12:34:56

The full mac address ends up being 52:54:00:12:34:56.

So, it was definitely the issue. If no mac is forced, the same is always applied to the qemu created vm.
Generating a random mac address and adding it to the boot commands via “ethaddr="fixes the issue.

Well, this is not fixed.

We have a first dhcp ip when creating the master via user-data, then, when it reboots on the created os, to finish setting it up, packer dhcp gives it another ip sometimes, even tough the mac address is the same.

Tested with packer 1.10, 1.12 and 1.14.1.

How is that ?

My bad, with packer 1.14.1 and forcing a random generated mac address when creating the qemu vm, it works.
Adding ethaddr in the boot commands isn’t even needed.

Something must have been fixed between packer 1.12 and 1.14.1.

packer-qemu should, in itself, create a vm with a random mac address, instead of using the same one by default.