Skip to content

Instantly share code, notes, and snippets.

@patrickdappollonio
Last active October 12, 2021 14:06
Show Gist options
  • Save patrickdappollonio/a82632298ca1e4536a2da488d0542f08 to your computer and use it in GitHub Desktop.
Save patrickdappollonio/a82632298ca1e4536a2da488d0542f08 to your computer and use it in GitHub Desktop.

Sharing Host VPN with VirtualBox guest

Actually, this already works using VirtualBox’s NAT networking mode in your guest. What doesn’t work is resolving domain names from the guest that are only known in the VPN network.

So if you have a a domain like w3.mycompany.com that only resolves using the VPN’s DNS, you can resolve that name from your host (which is connected to the VPN), but not from your guest by default. You won’t be able to ping w3.mycompany.com from the guest. However, if you try to ping the IP address from your guest, that works.

To solve this, VirtualBox has a nice feature to allow you to set the Host DNS resolver as the DNS proxy of a VirtualBox VM. To configure this, you first need to figure out the id of your VirtualBox VM:

$ VBoxManage list vms

Note that uuid of your VM and then:

$ VBoxManage modifyvm <uuid here> --natdnshostresolver1 on

Now try to ping that VPN domain name again from your rebooted guest. Works!


Source: Renier Morales Rodriguez

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment