Pragmatism in the real world

Sharing host VPN with Vagrant

When moving a project into Vagrant, I realised that I needed the vagrant guest to share my OS X’s VPN.

I’m using a separate IP address within a private network like this:

config.vm.network :private_network, ip: "192.168.101.101"

So, after some Googling, I added this provider configuration setting:

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

and now my VM is sending data over the VPN. Note that this will not work when using the Vagrant’s public_network setting though.