Windows – How to route HyperV VMs traffic through host VPN

hyper-vnetworkingroutingvirtual machinewindows 8

I'm using Windows 8.1 Pro with HyperV. I have several VMs for development, all of them connected with host via Internal adapter using network addresses:

192.168.10.0/24

Where:

192.168.10.1 

is my host's Hyper-V internal NIC address.

When I'm not in my office I use 3G usb dongle an dialup VPN connection. I would like to route traffic from all existing and future VMs through the VPN. In best scenario traffic would be routed only partially to the local company network addresses

10.1.1.0/24 

I don't want to use sharing because I'm switching between WiFi, USB 3G dongle and VPN. Moving to other virtualization is also not an option for me.

Best Answer

You must enable IPv4 forwarding on the host, which is OS-specific. Just Google it.

You also need to determine whether your hosts have a routing rule providing a default route through your host. It should exist, in which case you are all set. If it does not exist, you will have to do it by hand, and this too is OS-specific. But you can Google change default gateway in Windows/Mac OS/Linux/FreeBSD/whatever easily.

EDIT:

In order to enable IPv4 forwarding on your Windows host machine do the following:

1) Start Registry Editor (Regedit.exe).

2) In Registry Editor, locate the following registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

3) Set the following registry value:

 Value Name: IPEnableRouter
 Value type: REG_DWORD
 Value Data: 1

A value of 1 enables TCP/IP forwarding for all network connections that are installed and used by this computer.

4) Quit Registry Editor.

Now try pinging any IP address (8.8.8.8, for instance) from your guests, it should work.

Related Question