- Mac OS host machine (10.6+)
- VirtualBox (4.1+)
- Vagrant (1.0+)
- Connecting via VPN to a remote network
- Mounting a directory from your host machine to the guest machine using NFS with something like this:
config.vm.share_folder("www-data", project_mount_path, ".", :nfs => use_nfs)
When connecting to VPN, the client and configuration lock down all other local network connections. This causes an NFS mount initiated with Vagrant (1.0) to break. Trying to ls
an NFS-mounted directory or interact with any file from within the mount causes the VM to hang.
You can still mount host machine directories to your Vagrant machine without using NFS. Instead it will use vboxfs
, VirtualBox's default "shared folder" functionality. This is roughly 2x slower than NFS, and if you are writing lots of files back to disk into this directory from inside the VM it can cause write corruption, but hey, it works under some circumstances.
From your Vagrantfile
, change the following line:
config.vm.share_folder("www-data", project_mount_path, ".", :nfs => use_nfs)
and remove , :nfs => use_nfs)
config.vm.share_folder("www-data", project_mount_path, ".")
Now reload your VM:
vagrant reload
If simply reloading doesn't work, destroy the VM and re-provision it:
vagrant destroy
vagrant up
Now try connecting to your VPN, then interacting with your VM's mounted host directory by loading a web page or issuing an ls
on the directory itself. The directory should behave as normal.
Note: This solution may only work if your VPN provider uses Cisco AnyConnect client.
We'll assume you have Homebrew Package Manager for Mac installed. If not, the knowledge to compile packeges from source.
Install openconnect via homebrew.
brew install openconnect
Using openconnect
, connect to your VPN network. You may want to read the openconnect
man pages or help menu to read more about its options and the proper connection string for your network:
sudo openconnect [https://your.url.here]
Accept the cert and login using your credentials. You should now be connected without VM conflicts.
The initiated terminal window should not be closed in order to maintain the VPN connection.
- Jim Bouck - original idea and implementation on Linux
- Chris Escalante - instructions for Mac
- John Kary - curating and posting this document