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

3,349 views
Skip to first unread message

Péter Zsoldos

unread,
Feb 5, 2015, 4:09:24 AM2/5/15
to vagra...@googlegroups.com
(FYI: originally I've posted this question to stack overflow, not realizing this group is the better forum for it)

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

The host environment is:

  • Windows 7x64
  • 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 'devbox' 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.

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)

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?

Thanks,

Peter

Alvaro Miranda Aguilera

unread,
Feb 5, 2015, 5:22:34 AM2/5/15
to vagra...@googlegroups.com
hello, seems that do something with the dns..

not sure if this is the fix, but worth trying..

if the dns is the problem.. say the VM is using the host DNS / VPN
DNS.. then you can test.

try this on the VM when you don't have internet access as you say.

dig google.com

then

dig google.com @8.8.8.8

if doesn't work, try on the host

ipconfig /all

get the dns ip is setup

dig google.com @<ip_dns>

If the 2nd work, try to setup a diferent dns in /etc/resolv.conf

nameserver 8.8.8.8
nameserver 8.8.4.4
search <your domain>

repeat for the 3rd test if that works..

then you can put a shell provisioner to overwrite /etc/resolv.conf
> --
> You received this message because you are subscribed to the Google Groups
> "Vagrant" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vagrant-up+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages