Forum Discussion
Hyper-v Ubuntu 26.04LTS Multiple DHCP entries
Good evening,
am running windows server 2022 datacenter edition, which is running multiple hyper-v machines.
I have been installing a new instance of ubuntu 26.04.1LTS but have noticed something weird. Maybe you could assist.
Issue:
When fresh install Ubuntu 26.04.1 into a VM using hyper-v, I notice 2 IP addresses appear in windows DHCP (192.168.40.20, 192.168.40.21). When I shut down the instance only one disappears (192.168.40.21). If I delete 192.168.40.20 and restart the VM instance both Ip addresses reappear in DHCP.
Points to note:
Image was downloaded direct off the website with no changes (have redownloaded to make sure image is not broken)
Have tried using a different name for the server
Have noticed the ubuntu instance only picks up one address (192.168.40.21) for the adaptor.
Am unable to ping 192.168.40.20 or connect to that address via ssh.
Would anyone have any idea, where the second IP address would be coming from in DHCP?
1 Reply
- Manu_staOccasional Reader
Hi, I think I know what could be happening. The Windows DHCP server does not identify clients only by the MAC, it uses the client identifier that the client sends in the request. Ubuntu with netplan and systemd-networkd sends by default an identifier based on a DUID and not the MAC, so if something else asks for an IP using the MAC the server thinks they are two different clients and gives two leases.
In your case I would check two things.
First open the DHCP console, go to Address Leases and compare the Unique ID column of the .20 and the .21. If one of them is just the MAC of the VM and the other one is a long string, that's the problem.
Second, if it's a Generation 2 VM check the Firmware section in the VM settings. If the Network Adapter is above the Hard Drive in the boot order, the UEFI firmware tries a network boot first and asks for an IP with the MAC before Ubuntu starts. That would explain why the .20 never answers to ping and why it doesn't disappear when you shut down the VM, because only Ubuntu releases its lease and the firmware never does. Just move the hard drive to the top or remove the network adapter from the boot order.
You can also make Ubuntu use the MAC as identifier. Edit the yaml file in /etc/netplan and under your interface add dhcp-identifier with the value mac next to dhcp4 true, then run sudo netplan apply. After that delete the old lease in the DHCP console and restart the VM, you should only see one lease.
Hope it helps!