Cloning a VM and using a Host-only adapter with a DHCP server attributes the same IP to multiple VMs
Cloning a VM and using a Host-only adapter with a DHCP server attributes the same IP to multiple VMs
Hello,
I have been searching everywhere for a solution to this problem, and the only one that works is using sudo dhclient on every machine after it has booted which isn't very convenient.
The VMs are cloned with the "Generate new MAC addresses" option set. My DCHP server is correctly set as IPs are attributed to machines using the aforementioned command.
Creating a new VM and installing from scratch, its IP is properly attributed by the DHCP server.
Most other solutions point to changing the machine id, but this can only be done on Linux hosts and I am using Windows 10 Pro (2004).
Is there any actual way to fix this problem?
Thank you.
I have been searching everywhere for a solution to this problem, and the only one that works is using sudo dhclient on every machine after it has booted which isn't very convenient.
The VMs are cloned with the "Generate new MAC addresses" option set. My DCHP server is correctly set as IPs are attributed to machines using the aforementioned command.
Creating a new VM and installing from scratch, its IP is properly attributed by the DHCP server.
Most other solutions point to changing the machine id, but this can only be done on Linux hosts and I am using Windows 10 Pro (2004).
Is there any actual way to fix this problem?
Thank you.
-
scottgus1
- Site Moderator
- Posts: 20945
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows, Linux
Re: Cloning a VM and using a Host-only adapter with a DHCP server attributes the same IP to multiple
I have anecdotally seen some users' Linux VMs not respond to a change in IP address range when the Virtualbox network type is changed, and a reset of stored data about the network needed to be done inside the Linux VM OS. If I am not completely goofy in this assessment, it could be what you're facing. (I also am a Windows guy, so I don't know if this is true or how to properly handle it.)
Re: Cloning a VM and using a Host-only adapter with a DHCP server attributes the same IP to multiple
How would one go about doing that?scottgus1 wrote:a reset of stored data about the network needed to be done inside the Linux VM OS
Re: Cloning a VM and using a Host-only adapter with a DHCP server attributes the same IP to multiple
It turns out changing the machine id actually fixed the problem. When cloning a VM, this id isn't changed and that causes all VMs with the same id to get the same IP from the DHCP server.
-
BillG
- Volunteer
- Posts: 5106
- Joined: 19. Sep 2009, 04:44
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows 10,7 and earlier
- Location: Sydney, Australia
Re: Cloning a VM and using a Host-only adapter with a DHCP server attributes the same IP to multiple
That makes sense. A clone is just that - an identical copy. That is why you need to change the MAC address.
Bill
-
scottgus1
- Site Moderator
- Posts: 20945
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows, Linux
Re: Cloning a VM and using a Host-only adapter with a DHCP server attributes the same IP to multiple
Curious, here; how did you do this?Keagel wrote:It turns out changing the machine id actually fixed the problem.
Re: Cloning a VM and using a Host-only adapter with a DHCP server attributes the same IP to multiple
The MAC address wasn't the problem. When I cloned the VM, I actually choose the option to generate a new MAC address. I'm talking about the file /etc/machine-id.BillG wrote:That makes sense. A clone is just that - an identical copy. That is why you need to change the MAC address.
I somehow can't find where I got the solution from, but it was actually very simple:scottgus1 wrote:Curious, here; how did you do this?Keagel wrote:It turns out changing the machine id actually fixed the problem.
Code: Select all
sudo rm /etc/machine-id
sudo systemd-machine-id-setup
-
scottgus1
- Site Moderator
- Posts: 20945
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows, Linux
Re: Cloning a VM and using a Host-only adapter with a DHCP server attributes the same IP to multiple
Thanks for those commands!.
-
BillG
- Volunteer
- Posts: 5106
- Joined: 19. Sep 2009, 04:44
- Primary OS: MS Windows 10
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Windows 10,7 and earlier
- Location: Sydney, Australia
Re: Cloning a VM and using a Host-only adapter with a DHCP server attributes the same IP to multiple
I would say it uses that as well as the MAC rather than instead of the MAC.
Bill
-
fth0
- Volunteer
- Posts: 5690
- Joined: 14. Feb 2019, 03:06
- Primary OS: Mac OS X other
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Linux, Windows 10, ...
- Location: Germany
Re: Cloning a VM and using a Host-only adapter with a DHCP server attributes the same IP to multiple
Maybe I can shed some light on the background:Keagel wrote:I'm not sure why Ubuntu uses that instead of the MAC address.
In general, the DHCP Client Identifier option is used to identify the client. Since RFC 2132 (DHCP Options, 1997), the MAC address was often used for this. Since RFC 4361 (Node-specific Identifiers for DHCPv4, 2006), the DHCP Unique ID (DUID) was sometimes used instead, so that the Client Identifier is the same on multiple network interfaces and also when using IPv4 and IPv6. Since the current trend of MAC address randomization, the MAC address is sometimes used again for privacy reasons.
The Linux machine ID is used as the DUID when adhering to RFC 4361.
-
fth0
- Volunteer
- Posts: 5690
- Joined: 14. Feb 2019, 03:06
- Primary OS: Mac OS X other
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Linux, Windows 10, ...
- Location: Germany
Re: Cloning a VM and using a Host-only adapter with a DHCP server attributes the same IP to multiple
Why do you think that?BillG wrote:I would say it uses that as well as the MAC rather than instead of the MAC.
If a DHCP request contains the DHCP Client Identifier option, the DHCP server must use that identifier to identify the client (and not the chaddr field, which contains the MAC address). The Linux DHCP client can be configured what to use for the DHCP Client Identifier option, but I think it's either the MAC address or the DUID (or something else), but not both.
Re: Cloning a VM and using a Host-only adapter with a DHCP server attributes the same IP to multiple
Thanks for the detailed explanation!fth0 wrote:Maybe I can shed some light on the background:Keagel wrote:I'm not sure why Ubuntu uses that instead of the MAC address.
In general, the DHCP Client Identifier option is used to identify the client. Since RFC 2132 (DHCP Options, 1997), the MAC address was often used for this. Since RFC 4361 (Node-specific Identifiers for DHCPv4, 2006), the DHCP Unique ID (DUID) was sometimes used instead, so that the Client Identifier is the same on multiple network interfaces and also when using IPv4 and IPv6. Since the current trend of MAC address randomization, the MAC address is sometimes used again for privacy reasons.
The Linux machine ID is used as the DUID when adhering to RFC 4361.