skorhone / wsl2-custom-network

This project contains powershell scripts for creating custom network for WSL2
34 stars 5 forks source link

You perhaps helped solved a WSL2 Corporate-Enterprise VPN Clash WSL2 Broken Subnet Network after 13 years #2

Open KonanTheLibrarian opened 1 year ago

KonanTheLibrarian commented 1 year ago

Design Flaws Both in WSL2 Broken Network Settings and in Windows Continues to Plague Corporate Developers

I have been using WSL2 for 1 year in an corporate/enterprise setting. I can't thank-you enough, perhaps got a lead on a solution for a BILLION DOLLAR T-REX LEVEL BUG that first came out a long time ago with WSL1. WSL2 could so easily have been a flagship app of Microsoft, but for networking it SUCKS so bad many bigger companies forbid WSL2 use, WSL2 networking just fails to ping network dies randomly. Many frustrated users who hold down real jobs get so mad with WSL2 teams programmers who then get "hurt feelings" this problems is for sure beyond "hurt feelings" ALREADY.

I am a key Linux developer right down to my code running on every mobile network.
So me coding a C++ fix for Microsoft's by far most ignored bug is hilarious!

I have tried about 30 different approaches to the fix but the way WSL2 configures networks is broken at the design level, the design sucks. WSL1 and WSL2 teams have closed THOUSANDS OF BUG REPORTS, ALL 100% CRITICAL (not Major) and all UNFIXED. Yup thousands! So I comment on them closing it: "You are a genius, so glad you closed this bug as it therefor must be fixed magically with no code changes, you fixed a 13 year old CRITICAL bug."

The following bruit force and no intelligence script works RANDOMLY, but your one is intelligent.

echo "Restarting WSL Service"
wsl --shutdown
Restart-Service LxssManager
echo "Restarting Host Network Service"
Stop-Service -name "hns"
Start-Service -name "hns"
 echo "Restarting Hyper-V adapters"
Get-NetAdapter -IncludeHidden | Where-Object `
     {$_.InterfaceDescription.StartsWith('Hyper-V Virtual Switch Extension Adapter')} `
     | Disable-NetAdapter -Confirm:$False
 Get-NetAdapter -IncludeHidden | Where-Object `
     {$_.InterfaceDescription.StartsWith('Hyper-V Virtual Switch Extension Adapter')} `
     | Enable-NetAdapter -Confirm:$False

A primary symptom is if you manage to get WSL2 networks working the PC going to sleep breaks it but not other apps networks.

Sadly corporate/enterprise IT prevents PowerShell scripts from running even in admin mode in sensitive organisations (actually I approve of PowerShell being blocked as it is UNTRUSTED) - but ironically you can cut and past scripts (your nice script) into ADMIN PowerShell directly and it works. Hence I'm taking your solution and coding it in C++ but also creating another tool that displays the network configs (for randomly working WSL2 enterprise networks that work 1 in 8 reboots - hitting by accident an authorised subnet). 7 out of those 8 reboots triggering major security alerts - YA WAY-TO-GO WSL2 and Microsoft for your MAD and RANDOM network settings for WSL2 that violate security in a massive way that encourages IT to open the IP doors too wide to make buggy-wuggy-WSL2 work.

Windows applications work over the network just fine, but corporate/enterprise WSL2 Networks fail and it SUCKS!

Microsoft's most valued customers get this bug the most, and it's worse as IT prevent PowerShell scripts running even in admin mode. Your PowerShell fix is based off of some C or C++ code from here and that is a nice start. So thank-you.

pa-0 commented 5 months ago

A primary symptom is if you manage to get WSL2 networks working the PC going to sleep breaks it but not other apps networks.

I realize it's far from ideal, more of a band-aid than a solution really, but this might nevertheless help you avoid the above issue (at least for the time being). The (open-source) PowerToys suite includes a utility called:

"Awake"

that will prevent your machines from sleeping. You're probably already aware of something similar if not Awake, but just thought I'd throw it out there.

pa-0 commented 5 months ago

Also, I just noticed in your issue that you expressed the intent to write a program based on the pwsh function offered in this repo... How is that going?