Could DHCP server set up on Custom Nat Network in VirtualBox? I don't want to use VirtualBox default DHCP server. I want to fully control this service.
2 Answers
Not possible - paradox of the chicken and the egg.
The host needs to get its IP address when it boots, which is before starting VirtualBox and booting the VM.
Having two DHCP servers on the same local network is not workable.
-
Not entirely true. DHCP can be set to static to circumvent the problem. A host and guest can both have a static ip address and then you can use DHCP inside the server no issues. Also, with a dynamic ip, if you have physical access to the server, you can boot the guest fine, get the dhcp server up, and then renew the host's ip address.– LPChipCommented Aug 28, 2023 at 11:06
-
@LPChip: Using static IP is an easy solution, but defeats the purpose of using DHCP servers.– harrymcCommented Aug 28, 2023 at 11:35
-
Having static IP addresses but it works, vs it is impossible is another argument.– LPChipCommented Aug 28, 2023 at 12:28
I'll write my answer too even if its more of a workaround, for those that come to this question and find benefit from this.
I run my virtual server inside VirtualBox and use its DHCP server with no issues.
For this to work, I have done the following:
In VirtualBox, the network connection is set to bridge, so that the VM's network is placed outside of VirtualBox, and NAT is no longer necessary. My router now controls NAT.
The server host and server guest themselves have been given a static ip so that they always have an ip address. After installing the DHCP server role on it, it now acts as the DHCP server, and other network devices can get a lease from it.