Where 10.8.0.5 is your tun0 gateway and 192.168.5.0/24 is your vboxnet0 network range. Last step is routing the packets coming from vboxnet0 into your VPN. Make the default gateway of Guest point to Host's ip ifconfig vboxnet0 to find it.Change the network type of Guest System to be "Host Only".
Update 2019: this feature has since matured: attach to the host's NAT and choose the Paravirtualized network (virtio-net) adapter type. Try VirtualBox's experimental NAT Networking configuration. This will require no changes in the interface configuration you now have in the VMs, but you will need to set up the host to be the gateway and router, and make it NAT the VMs to the outside (whether across its eth0 or tun0).Ĭombine the above: give each VM two interfaces, one gatewaying to the outside world (across VirtualBox's NAT) and the other attached to the Host-Only LAN. Use Host-only Networking to create a proper subnet containing the VMs and the host. However this precludes connections from the host to the VMs or connections between the VMs.
VirtualBox will NAT the VMs across whatever internet connection is available to the host. Network Address Translation (NAT) is by far the simplest solution. You will need to use a different virtual networking configuration. Since your virtual machines are using eth0 directly, they are unaware of the tun0 interface to the tunnel running over it. Packets directly, circumventing your host operating system's network When enabled, VirtualBoxĬonnects to one of your installed network cards and exchanges network This is for more advanced networking needs such as network simulationsĪnd running servers in a guest. This will not work in a Bridged Networking setup. One of the VMs /etc/network/interfaces file: # The loopback network interface I suspect that the solution will have something to do with the routing table. TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1 TX packets:381963 errors:0 dropped:0 overruns:0 carrier:0 RX packets:381963 errors:0 dropped:0 overruns:0 frame:0 TX packets:182601 errors:0 dropped:0 overruns:0 carrier:0 RX packets:165426 errors:0 dropped:0 overruns:0 frame:0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 However when I start my VPN tunnel on this router, internet connectivity is lost for the VMs on the eth0 subnet (yet remains for the router).īelow is the output of ifconfig when the tunnel is active: eth0 Link encap:Ethernet HWaddr 00:1f:bc:01:c3:ab The packets on the eth0 are forwarded through eth0:0 with masquerading and normal internet connectivity is fine. This is shown in the /etc/network/interfaces file: auto lo Subnet 192.168.0.0/24 on eth0:0 which connects to gateway 192.168.0.1 which has internet access. Subnet 172.16.0.0/20 on eth0 for my VirtualBox virtual machines.
Ideally, I would like to know how to enable the attached subnet to re-gain internet access by routing through the VPN tunnel when the VPN is active. When I start my VPN on my ubuntu desktop computer which acts as a router, the attached subnet loses internet connectivity, but is still accessible (LAN).