Assign multiple IP addresses in NAT mode to the same VM

tsuna asked:

I’m aware that VirtualBox assigns the same IP to different VMs (by default 10.0.2.15), however I have a case where I have a VM with a single vNIC, and a Linux namespace inside the VM attempts to get an IP from DHCP, and it gets the same IP from VirtualBox. So both eth0 and the other interface inside my network namespace have the same IP address, which is obviously wrong.

Is there a way to have VirtualBox correctly return different DHCP responses or is it a limitation of VirtualBox that it doesn’t correctly handle DHCP requests coming from different source MAC addresses from the same VM?

My answer:


In NAT networking mode, VirtualBox machines can talk to the Internet, but not to each other.

In host-only networking mode, the virtual machines can talk to each other, but not to the Internet. (Though you could NAT them manually if you are on a Linux or FreeBSD host.)

Another option is VDE networking; this is only available in the community edition, and not the Oracle edition of VirtualBox, and only on Linux and FreeBSD hosts. It’s much more involved to set up, but would do what you want once done.

The fastest and easiest way to set this up is, of course, bridged mode.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.