Go to ...

RSS Feed

September 25, 2020

Hyper-V Virtual Machine – Use Host VPN Connection

When your Hyper-V host computer is connected to a VPN, virtual machines still use the host’s default connection. They are not connected to the VPN. This is often practical, in fact. Thus, for example, while VPN allows my host to use another geolocation, I can use a virtual machine on that same host for services that require my real location.

In the following screenshot, my host computer is connected to F-Secure Freedome VPN. It’s using a location in my native Finland, as the IP Lookup shows (blue highlight). At the same time, a Windows 10 virtual machine running on that host is still using the host’s default geolocation, my adopted home country of Germany (yellow highlight):

Click screenshots to view enlarged in a new tab.

This is the default setup, whatever VPN client you might use.

But, what if you need a VPN connection on your virtual machines? One solution is to buy an extra license, to install on a VM. Otherwise, If you are like me and make a wrong choice when buying a VPN, ending up with something like Freedome, you are in big trouble. The license allows Freedome to be installed on three devices. Unlike most of their rivals, Freedome does not offer an admin panel where you can manage your licenses, remove one from machine you want to reset or reinstall Windows, then add the freed license for that machine when done. When you contact their support, they simply tell you that moving license to another machine is not possible. This, licenses being not transferable, makes Freedome about as bad a choice as possible, especially for Windows Insiders like me who might clean and re-install several times a month. Think if other software licenses were like that: “If you reinstall Windows, you lose your license to our software“.

OK, enough ranting. So, what to do when you don’t want to spend money for a VPN client for VM, and cannot transfer your existing licenses? Simple: just set up your Hyper-V virtual machines to use the host’s VPN client and connection.

To start with, create an Internal Switch in the Hyper-V Virtual Switch Manager:

See Part Three of my Hyper-V tutorial on Ten Forums for detailed instructions on creating virtual switches.

Now, on the host, connect to a VPN. When a connection is established, open Network and Sharing Centre, and select Change adapter settings:

Right-click your VPN connection, select Properties, select the Sharing tab, enable sharing and select your Internal switch:

The only thing still missing is to set your VM to use the Internal switch in its VM settings:

That’s it. Checking the geolocation with IP Lookup on that VM now, you will see it uses the same geolocation as the host:

This technique is easy, fast and practical. It’s also cheap: you do not need a VPN client especially for your VM, when the host already has one!


Author: Kari Finn

A former Windows Insider MVP, Kari started in computing in the mid 80’s writing code for VAX / VMS systems. Since then, he’s worked in a variety of IT positions. He specializes in Windows image capture, customization, repair and deployment as well as Hyper-V virtualization. Kari is a proud Team Member at number #1 Windows site TenForums.com.

15 Responses “Hyper-V Virtual Machine – Use Host VPN Connection”

  1. locksmith
    February 10, 2020 at 18:35

    Very elegant. Thank you.

  2. Thanks
    March 20, 2020 at 01:39

    thanks for this :p

  3. ksmith
    March 20, 2020 at 19:21

    Awesome post. I got it to work very easily.

    I have a question about where you said “When a connection is established, open Network and Sharing Centre, and select Change adapter settings” to share the VPN with my internal switch.

    It says the VPN connection has to be established before sharing it with the switch. I did this the first time to set up and it worked fine. Later, I disconnected and reconnected to VPN. My VM lost its internet connection. I then unshared and reshared the VPN connection and the VM worked again.

    Do I have to reshare the VPN each time or should it remain shared even when VPN is disconnected and later reconnected?

    • March 20, 2020 at 19:35

      My experience is that it is a bit “Hit and miss”. Theoretically, when you have once shared the host VPN connection with Hyper-V Internal switch, it should work always when VPN is running. In practise, sometimes you must do what you did, unshare and share again. In total honesty, I have not a faintest clue why.

  4. Tony Burnett
    April 5, 2020 at 17:13

    When I try to enabled sharing on either of my 2 VPN NICs I get a pop-up error…

    “Cannot enable shared access. Error 87: the parameter is incorrect”

    • April 5, 2020 at 23:07

      Which VPC client you are using?

  5. Mark Hansen
    April 7, 2020 at 19:10

    I’m using Pulse Secure for my corporate VPN while working from home. When I go to “Change adapter settings” to adjust the sharing options on the VPN adapter, I get an Access Denied error. I’m an Administrator on this machine, so I don’t think it is a permissions issue. Is this due to the adapter being in-use, or the wrong type of VPN? I’m really hoping to get this working.

  6. Johan
    April 10, 2020 at 13:53

    I only got it right by installing and running VPN (Cisco Anyconnect) within the VM, and not running it in the host

  7. howierd
    April 21, 2020 at 02:00

    Thanks! It worked with Cisco AnyConnect 4.7.04056. I had to enable “Allow local (LAN) access when using VPN (if configured)” for it to work.

  8. Digi
    April 24, 2020 at 21:14

    This was a life saver for me! My VMs were crawling with the local VPN connection, thank you.

  9. Swaminathan Shanmugam
    July 20, 2020 at 14:43


    I am able to ping the site in VPN network from the VM but the site is not opening

    Any help please!


    Swaminathan S

  10. Anonymous
    August 24, 2020 at 21:26

    But the VPN sharing is disabled by compnay network admin

  11. August 24, 2020 at 21:28

    network admin disabled vpn sharing. No local network accessing due to security reason

  12. Anonymous
    September 9, 2020 at 14:38

    I cannot for the life of me get my hyper-v machine to use the windows standard vpn on my machine. As soon as I connect to the VPN on the host the VM network dies. No matter how many times I try creating a switch, renaming, re-sharing the link, nothing is helping. Getting ready to flip the table.

  13. Jieke
    September 11, 2020 at 09:46

    This didn’t work for me, my Ubuntu VM does not get any IP address. I tried with and without VPN (setting normal resp. VPN interface to share with Internal).
    In addition this does not work seem to work with Zscaler (which does not create any VPN Interface).

Leave a Reply

More Stories From Hyper-V