Vagrant - share host VPN with guest

5,677

If you are using Virtualbox as your VM provider, I've successfully used this snippet to enable the use of a host VPN connection on a guest VM.

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

You may have seen the following code snippet online which no longer works on newer versions of Vagrant:

Replaces the earlier config.vm.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
Share:
5,677

Related videos on Youtube

George K.
Author by

George K.

Updated on September 18, 2022

Comments

  • George K.
    George K. over 1 year

    So I have an interface for a VPN connection (jnc0), and also a vagrant guest which talks to my machine through another separate interface (vboxnet1). My host OS is OS X Mountain Lion, and the Vagrant (VM) guest OS is CentOS 6.3.

    How can I set something up so that the CentOS guest will be able to talk to hosts on the other side of the VPN through my OS X host?

    • Mxx
      Mxx over 11 years
      Do you need external clients to connect to your VM?
    • Mxx
      Mxx over 11 years
      Also, can you configure your guest to establish its own separate VPN connection independent of your host?
    • George K.
      George K. over 11 years
      I want to be able to connect to the servers on the other side of the VPN from my VM (so NAT is fine), and no I can't, since the VPN features three-factor authentication, and I can only do it from my host OS.
  • Johan Fredrik Varen
    Johan Fredrik Varen over 6 years
    Saved my day, mate!