Windows – vagrant provisioned virtualbox cannot access the internet when booted up with an active VPN connection on the windows 7 host

Ubuntuvagrantvirtualboxvpnwindows

I have a problem with networking while setting up a development virtual machine

The host environment is:

  • Windows 7×64
  • Vagrant 1.7.2
  • Virtualbox 4.3.20 r96997
  • has an active WLAN internet connections
  • can connect to a VPN

The relevant sections from the Vagrantfile are:

ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'
Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/trusty64"
  config.vm.define 'crm' do |node|
    node.vm.network :private_network, ip: '192.168.56.2'
  end
end

With this, the guest machine has two network interfaces:

  • eth0: NAT
  • eth1: the private network

After a vagrant up the machine is always accessible through the private IP.
However, if at boot time the VPN connection

  • is active, then the guest machine cannot access the internet
  • is not active, then the guest machine can access the internet

On the host machine, with an active VPN connection, both public and VPN-restricted hosts are accessible.

Question: how should I modify the Vagrantfile to ensure that the guest machine always has internet access, regardless whether it was booted with an active VPN connection on the host machine or not?

Update:
adding

config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end

solves the internet connectivity issue, however, it brings the boot time of the guest machine to barely tolerable (many minutes)

Best Answer

ok. i had the same problem but i am using windows. i did fix it. what i did is that opened virtualbox.

  1. go to settings

  2. select network

  3. change second adapter

  4. select under " attached to: " ' Host-only Adapter'

  5. under name. i selected " virtualbox host-only ethernet apdapter " do not select the name that have numbers at the end of the name example : #1, #2 and so on.

  6. i went to my device manager and delete all the virtual network drivers "not your physical network drivers". again this was in windows 8.

  7. i restart my pc

  8. confirm my chance have applied

  9. i vagrant up on my project directory and it was working

Related Topic