micahmo / WgServerforWindows

Wg Server for Windows (WS4W) is a desktop application that allows running and managing a WireGuard server endpoint on Windows
MIT License
892 stars 86 forks source link

WG server always use lowest metric adapter in multiple lan environment #129

Closed HunWatt closed 7 months ago

HunWatt commented 1 year ago

Hi! I have got two 2.5 gbe LAN interface, LAN1 metric is 10 and LAN2 is 25. Windows uses LAN1 for default, but i would like to share LAN2 internet for vpn, but it doesn't work that way because LAN1 is the first adapter for everything and the wg server would also use this. In this case the handshake no longer works until I reduce the lan2 metric below lan1. Can the l2 adapter only be forced to wg server?

micahmo commented 1 year ago

Hey @HunWatt, thanks for the report, your use case definitely makes sense. NAT on Windows is notoriously limited in terms of its functionality, and it's very possible that there's no way to control which adapter it uses. I can certainly look into this. However, a potentially easier solution is to use Internet Connection Sharing instead of NAT. That would allow you to choose the specific adapter you want to share with WireGuard. Can you give that a try and let me know if it works?

HunWatt commented 1 year ago

Hi @micahmo For me, it only works with sharing if I reduce the metric of the shared adapter. For example, Lan1 metric 10 Lan2 metric 25 and I share Lan2, but it still uses Lan1. Could it be a unique case?

micahmo commented 1 year ago

Hey @HunWatt, apologies for the delayed response, and even more for the lack of a good answer.

I tried to reproduce your scenario, but I can't. For one, the handshake works fine for me regardless of which adapter has the lower metric. But more importantly, using ICS works to let me share the higher metric with the WireGuard network. I tested this by running a little web server elsewhere on my network, and my Windows desktop connects to the server over the lower metric, while my remote device connected to the WG server connects to the server over the adapter that I shared using ISC in WS4W.

That being said, this may not be a great test. My two adapters are both connected to the same LAN (WiFi and Ethernet), so it may not mirror your setup exactly. 😞

Let me know if there's anything else I can try.

HunWatt commented 1 year ago

Hello @micahmo I have no idea, but I can use it anyway. Later I will make some changes in my network, i have 2 separated isp.