none
How to share VPN connection with virtual Hotspot by routing code in Windows 10?

    Question

  • I make a virtual network adapter and want to share VPN with users who connected to this virtual network. This is the command line I use:

    netsh wlan set hostednetwork mode=allow ssid=W key=99999999

    netsh wlan start hostednetwork


    In the first step, I can make this hotspot successfully and I can share VPN connection with the virtual network adapter I made by the following direction:
    VPN connection > Properties > Sharing

    My question is how to do the same sharing with routing code without the sharing VPN connection?

    My virtual network adapter IP is: 192.168.137.1
    My VPN connection IP is: 136.243.169.39

    I wrote this route but sharing didnt wotk:

    c:\windows\system32\route.exe add 0.0.0.0 mask 255.255.255.0 136.243.169.39 metric 1



    • Edited by Amin2234 Wednesday, April 17, 2019 7:07 AM
    Wednesday, April 17, 2019 7:04 AM

All replies

  • Hi,

    0.0.0.0 means all unknown route will be assigned to this one, normally is to Internet, so the mask is 0.0.0.0 as well. 

    And if you want to connect your virtual network with VPN, why use 0.0.0.0 as the destination? use the VPN's network IP as destination is much better.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Thursday, April 18, 2019 2:41 AM
  • Hi,

    0.0.0.0 means all unknown route will be assigned to this one, normally is to Internet, so the mask is 0.0.0.0 as well. 

    And if you want to connect your virtual network with VPN, why use 0.0.0.0 as the destination? use the VPN's network IP as destination is much better.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Hi,

    Could you please explain with an example? You mean this?:

    c:\windows\system32\route.exe add 136.243.169.39 mask 255.255.255.0 136.243.169.39 metric 1

    Thursday, April 18, 2019 9:27 AM
  • Hi,

    As I understand, you have a server, and it has a virtual adapter is 192.168.137.1, and it has already connecting to VPN 136.243.169.39, the private network of this VPN, for example, is 192.168.1.0/24.

    So the destination is 192.168.1.0/24, not 136.243.169.39.

    And add this route to all clients that connect to 192.168.137.1 : route add 192.168.1.0 mask 255.255.255.0 192.168.137.1 if 1 metric 1

    normally, in server, virtual NIC and VPN NIC is already routed, you don't need to add another route entry.



    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Thursday, April 18, 2019 10:49 AM
  • Hi,

    As I understand, you have a server, and it has a virtual adapter is 192.168.137.1, and it has already connecting to VPN 136.243.169.39, the private network of this VPN, for example, is 192.168.1.0/24.

    So the destination is 192.168.1.0/24, not 136.243.169.39.

    And add this route to all clients that connect to 192.168.137.1 : route add 192.168.1.0 mask 255.255.255.0 192.168.137.1 if 1 metric 1

    normally, in server, virtual NIC and VPN NIC is already routed, you don't need to add another route entry.



    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Hi,

    I'm still unable to get it. Could you please send me a code sample for this?

    Based on this info, what is the routing code?

    Main network adapter IP: 192.168.1.10

    Hotspot virtual network: 192.168.137.1

    VPN connection IP: :136.243.169.39

    Saturday, April 20, 2019 9:19 AM
  • Hi,

    When connecting in VPN environment, the public IP address of you VPN server is not useful, you should point out the internal  IP address of your VPN network. For example, I internal network IP is 192.168.0.1/24, and my VPN server public IP address is 1.2.3.4, the destination of the route entry should be 192.168.0.1/24. Of course your internal network IP address may contains many subnets like 192.168.0.1/24 and 192.168.1.1/24, then you should add two entries.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, April 22, 2019 3:42 PM
  • Hi,

    When connecting in VPN environment, the public IP address of you VPN server is not useful, you should point out the internal  IP address of your VPN network. For example, I internal network IP is 192.168.0.1/24, and my VPN server public IP address is 1.2.3.4, the destination of the route entry should be 192.168.0.1/24. Of course your internal network IP address may contains many subnets like 192.168.0.1/24 and 192.168.1.1/24, then you should add two entries.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Hi,

    Unfortunately your explanation is not working in real environment. Please write it with code (routing code/script) if you think your solution is working.

    Wednesday, April 24, 2019 5:00 PM