Linux – Can’t ping between two virtual machines using VirtualBox host-only adapter in OS X

linuxmacosnetworkingvirtualbox

I am trying to run Kali Linux in one VirtualBox, and a De-ICE machine in another VirtualBox on a Mac (OS X 10, if it matters). I want to use the host-only adapter to connect the machines so the Kali machine can attack the De-ICE machine.

For those who don’t know De-ICE is an emulated Linux server meant to be penetrated for educational purposes, which means I can’t log into it. Netdiscover on Kali will show the IP address of De-ICE (192.168.1.20), but using nmap and ping on this IP will not work. nmap gives me the following message; pings are just lost:

failed to determine route to 192.168.1.20

In the general VirtualBox settings I created the host-only adapter (vboxnet0), and have messed around with the settings without success. One thing I noticed is the DHCP sever said the lower bound was 192.168.56.100 which is above 192.168.1.20 so I lowered it, but that didn't help.

In the settings of Kali and De-ICE I set them both to use the Host-only adapter vboxnet0.

A few weeks ago switching to the bridged adapter worked, but now that won’t work either, even though I haven't touched Virtualbox in the meantime. I did change the actual router my computer is on since then, so maybe that is the problem. Realistically though, I want to get the host-only adapter working rather than use a work around.

The weird part is I was at a friends house who has a PC, so I tried it on this completely different computer on a completely different network, and it still did not work.

Additional info:

I believe the De-ICE machine is set to always use 192.168.1.20, and can't be changed as far as I know. Netdiscover will show two versions of the machine. One at 192.168.1.20 and one at 192.168.56.100, but nmap and ping do not work on either. Maybe the problem is the DHCP server being run by Virtualbox is assigning one IP address, but De-ICE is defaulting to another? If so, how can I change what Virtualbox assigns to De-ICE, since De-ICE can't be changed?

Here is what I am seeing in Kali:
kali screenshot

So I changed to these settings, and it seems to be working now.
Virtualbox settings 1

I'm having a real Charlie Brown moment here because I swear this is exactly what I did before I came here and it didn't work, but it seems ok now.

In my exasperation I rudely forgot to thank you for your help, so I'll say it now. Thank you!

Best Answer

You say you have a host-only adapter setup, but what settings do you have in VirtrualBox for vboxnet0? To my knowledge, there are two places where the network settings need to be adjusted.

I’m using a Mac as well, but the general concept should be the same for anyone else using VirtualBox on Windows or Linux. If I go to “Preferences” when I launch VirtualBox and then click the “Network” icon and then click the “Host-only Networks” tab, I get a list of adapters I have setup:

enter image description here

Then—as shown in the screenshot—if I select vboxnet0 and then click the screwdriver icon, I can change options. Screenshot below:

enter image description here

I have the “IPv4 Address” set to 192.168.56.1 and the related IPv4 Network Mask set to 255.255.255.0. Now I usually have the DHCP server disabled as shown in the following screenshot:

enter image description here

But in your case it seems like De-ICE needs DHCP to get a connection, correct? If that’s the case, then perhaps the issue is you seem to have your vboxnet0 network set to the 192.168.1.x subnet? To my knowledge, the VirtualBox host-only setup always uses the 192.168.56.x setup. So I am not clear why De-ICE would get an address in the 192.168.1.x range unless the settings under Preferences -> Network -> Host-only Networks were adjusted. Would recommend checking that and ensuring the subnet is 192.168.56.x.

Also, you say this:

One thing I noticed is the DHCP sever said the lower bound was something about 192.168.1.20 so I lowered it, but that didn't help.

All that means is that the DHCP server would begin assigning IP addresses from 192.168.1.20 to the upper bound setting. Which is why De-ICE got assigned an address of 192.168.1.20; that was the first device to connect to the DHCP server on the VirtualBox host-only adapter. That is fairly meaningless and should not be lowered. Leave that as is. But like I said, I believe the range should be in the 192.168.56.x scope; not 192.168.1.x.