Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vagrant with VPN connection over host computer

Tags:

vagrant

vpn

I'm trying to get my Vagrant CentOS box connected to VPN thru my host computer. I followed this: https://gist.github.com/mitchellh/1277049

but I still can't connect to the VPN only hosts.

I'm on Vagrant version 1.3.5 and CentOS release 6.4.

Vagrant configs: config.vm.network :public_network and, as noted by the link above, I have

vb.cusotomize["modifyvm", :id, "--natdnshostresolver1", "on"]

With this setup I don't get any errors, it just doesn't seem to be working. I can reach hosts on my host machine but not thru my VM. When the VM is booting I choose my 2) en0: Ethernet 1 connection.

like image 523
dsmrt Avatar asked Dec 02 '13 22:12

dsmrt


2 Answers

As Terry Wang answered, remove public_network and as then follow this answer https://superuser.com/questions/542709/vagrant-share-host-vpn-with-guest

The newer versions of Vagrant will only use host as dns with this:

config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
like image 50
flurdy Avatar answered Nov 15 '22 11:11

flurdy


The Gist 1277049 is using default NAT networking for the Vagrant box.

However, you are using Public Network (Bridged) with your en0. That's why it is NOT working.

NOTE: I don't think you can bridge to a VPN connection (virtual adaptors, no driver). By using NAT, you are able to access the systems on the other side of the VPN connection.

To fix, just comment out the config.vm.network :public_network line. By default it'll use NAT and the box should be able to access whatever the host is capable of.

like image 35
Terry Wang Avatar answered Nov 15 '22 11:11

Terry Wang