Oracle VirtualBox’s is a robust virtualization solution and pretty much self-complete. So far, most probably you have used its built-in networking support without worrying about setting up an external DHCP server, e.g. TFTPD32 to supply network parameters to dynamic guest interfaces. The virtual machine receives its network address and configuration on the private network from a DHCP server integrated into VirtualBox. The server can be managed using VBoxManage dhcpserver command from command line or from the GUI, too. So far, so good.
Built-in server is a basic one, yet sufficient to meet the need of most of the applications unless you are into some advanced stuffs, viz. you may want to pass a dhcpd-option to the DHCP client sitting inside VM guest. One workaround is to set the VM to use Host-Only Adapter, disable the built-in DHCP server and run an external one. Ideally, the solution should work out-of-the-box. Probably due to a bug in VirtualBox 4.3.10 (on both Windows 7 Professional x64), it does not. Essentially, even after disabling the built-in DHCP server (220.127.116.11) and running a TFTFD32 server bound to VirtualBox Host-Only adapter (192.168.56.1) on host network, Ubuntu VM still receives DHCP OFFER packets from 192.168.56.100, i.e. the built-one. Attached is a transcript of DHCP cycle as captured by Wireshark.
The workaround I found is as follows:
- Remove built-in Host-Only Ethernet Adapter from Oracle VM VirtualBox Manager UI => File => Preferences => Network => Host-Only Networks tab => Select the adapter to be removed => Click on the second button on the right sidebar => Confirm removal
- Add a new adapter by clicking on the first button on the right sidebar of the same page. If asked, browse VBoxNetAdp.sys driver. On my system, it is located at C:\Program Files\Oracle\VirtualBox\drivers\network\netadp.
- Set appropriate IP (here 192.168.56.1) and netmask (here 255.255.255.0) for the adapter by clicking the third button on the right sidebar of the same page. If you face the problem of IP and/or netmask getting reset, please refer to this post.
- Make sure built-in DHCP server bound to newly created interface is disabled from the ‘DHCP Server’ tab. ‘Enable Server’ check-box must be unchecked.
- Verify that built-in DHCP server not running from command line by issuing ‘VBoxManage list dhcpservers‘ command.
- Set appropriate parameters in TFTPD64 DHCP settings. Don’t forget to bind it to the IP (here 192.168.56.1) of the new adapter.
- Boot up VM and verify the IP assigned to the guest interface by running ifconfig ethX (X = appropriate interface number). Also, the DHCP server offering the lease can be identified by running cat /var/lib/dhcp/dhcp/dhclient.ethX.leases | grep dhcp-server-identifier (X = appropriate interface number) command.
- Verify the same from the MAC <=> IP binding as displayed by TFTP64 main console.