1

I'm trying to establish a route between my local machine (LM) and a VirtualBox VM (VM, create with Vagrant and configured with Host-only Networking) running on a remote server (RS). The setup is as follows:

LM (OS: Windows 7, IP: 192.168.2.8)
VM (OS: Ubuntu server 14., IP: 192.168.50.4)
RS (OS: Ubuntu server 14., eth0: 192.168.2.204, vboxnet0: 192.168.50.1)

I tried to add the following route to my local machine:

route add 192.168.50.0 mask 255.255.255.0 192.168.2.204

But I can only ping the second interface (i.e. 192.168.50.1) of the remote server and cannot reach the VM. How I could fix this?

bachr
  • 163
  • 1
  • 5
  • 11

1 Answers1

2

Usually VMs in VirtualBox are added with NAT, so the VMs interface isn't directly exposed on the network. To expose it open Settings->Network and change "Attached to:" from NAT to Bridged adapter. You can then decide if you want to use DHCP or static addressing inside the VM.

Host-only Networking only provides access to the host and other VMs on the same machine, and is used when there is no need for the host's physical network interface.

To set up bridged adapter with Vagrantfile:

DHCP

Vagrant.configure("2") do |config|
   config.vm.network "public_network"
end

Static IP

Vagrant.configure("2") do |config|
   config.vm.network "public_network", ip: "192.168.2.205"
end
JonC
  • 136
  • 3
  • There's no GUI on the remote server (it is a ubuntu server) – bachr Mar 02 '15 at 15:43
  • 1
    You can use VBoxManage to modify the vm settings from the command line. The command should be something like `./VBoxManage modifyvm --nic1 bridged` – JonC Mar 02 '15 at 18:25
  • I need to do specify this through the [Vagrantfile](https://docs.vagrantup.com/v2/networking/public_network.html) and not directly with virtualbox command line – bachr Mar 03 '15 at 09:13
  • 1
    @Arbi, I extended my answer to cover the setup in Vagrantfile. – JonC Mar 03 '15 at 09:44