Page 1 of 1

VirtualBox DHCP server not leasing IPs in Host-only mode

Posted: 27. Jun 2017, 15:35
by porvik
Hi, I am running host Ubuntu 16.04.1 LTS. There I have installed latest VirtualBox and imported VM that is running SLES 9 image. My default SLES 9 VM has preconfigured one network interface set to DHCP and I have no DHCP server on my network.

The objective is that after importing, SLES 9 VM will be used in headless mode and connected to by SSH but most importantly without any manual intervention i.e. opening the VM UI console and manually modifying network interface settings or similar.

Therefore I have thought about:
1. Changing preconfigured network interface from Bridged mode to Host-only mode
2. Adding second interface in Bridged mode (this one is to be configured)
3. Adding host only adapter
4. Turning on build in VirtualBox built-in DHCP server, using limited range of addresses to be assigned (1 possible address)
5. Turning on guest VM and establishing connection to the one possible IP address
6. There I would be running some bash scripts that would configure second interface to use static IP address that could be used for any further connections
7. (Optional) remove first DHCP interface

Commands I have run after the import are:

Code: Select all

# 1. Changing preconfigured network interface from Bridged mode to Host-only mode
VBoxManage modifyvm "sles9vm" –nic1 hostonly
VBoxManage modifyvm "sles9vm" –hostonlyadapter1 "vboxnet0"

# 2. Adding second interface in Bridged mode (this one is to be configured)
VBoxManage modifyvm "sles9vm" --nic2 bridged --bridgeadapter2 eth0

# 3. Adding host only adapter
VBoxManage hostonlyif create
VBoxManage hostonlyif ipconfig vboxnet0 --ip 192.168.56.1

# 4. Turning on build in VirtualBox built-in DHCP server, using limited range of addresses to be assigned (1 possible address)
VBoxManage dhcpserver add --ifname "vboxnet0" --ip 192.168.56.2 --netmask 255.255.255.0 --lowerip  192.168.56.5 --upperip 192.168.56.5 –enable

# 5. Turning on guest VM and establishing connection to the one possible IP address
VBoxManage startvm "sles9vm" --type headless
Now always when I try to SSH to 192.168.56.5 it does not simply work. Therefore I have tried to stop guest VM and to run it in the UI mode. Then I logged into the guest system and check ifconfig. As expected there were no DHCP assigned address. So I have tried to restart network interfaces on guest VM but I still get the same issue saying that no IP assigned yet ... waiting.

Therefore I would like to know if anybody has experience with similar setup and maybe knows that I am missing. I have read documentation on Virtual Box and lots of forums but this does not seems to be common problem.