How to access a VirtualBox host-only network from outside the host machine


I'm using Vagrant to deploy a large virtual network environment for testing out some applications and network activity. I'm using host-only networking so I can define all the IP addresses in my Vagrantfile, but one of the applications I'm required to use for testing is an external appliance that cannot run as a virtual machine.

So, I'm wondering if it's possible to route traffic incoming to the host machine destined for the host-only LAN. I know this goes against the idea of host-only networking, but I cannot use bridged networking in this case because Vagrant isn't able to set static IP addresses on bridged guest interfaces.

I've tried the following:

  1. Added route on appliance telling it to use external IP address of VirtualBox host as the gateway for any traffic destined for the host-only LAN.
  2. Turned on IP forwarding on VirtualBox host
  3. Added route on VirtualBox host to forward any traffic destined for the host-only LAN to the vboxnet0 interface.
  4. Tried pinging one of the VirtualBox guests on the host-only LAN from the external appliance — no success.

Any ideas if this is at all possible?


It might be worth noting that I can ping the IP address of the host-only interface on the VirtualBox host (interface vboxnet0) from the external appliance.

Best Answer

  • Turns out I forgot a step... I needed to add a route to the virtual guest telling it how to get to the external LAN my appliance is sitting on via the IP address of the vboxnet0 interface on the VirtualBox host. Once I did this, I was able to communicate with it externally.

    thanks @Sirex for commenting on my question enough to make me think about it more!

  • Related Question