Skip to content

Instantly share code, notes, and snippets.

@benjamind
Last active June 9, 2022 16:47
Show Gist options
  • Save benjamind/c1d36a1e2bf30145dabc4d07231f4ce4 to your computer and use it in GitHub Desktop.
Save benjamind/c1d36a1e2bf30145dabc4d07231f4ce4 to your computer and use it in GitHub Desktop.
GlobalProtect WSL 2 Networking fix

Add the following as a scheduled task:

$wslInterface = (Get-NetAdapter | Where-Object Name -like "*(WSL)*" | Where-Object Status -like "Up" | Get-NetIPAddress -AddressFamily IPv4)
$wslIP = (wsl hostname -I)
$wslIF = $wslInterface.InterfaceIndex
Invoke-Expression "route add $wslIP mask 255.255.255.255 $wslIP metric 256 if $wslIF"

Triggered on Log Microsoft-Windows-NetworkProfile/Operational Source NetworkProfile EventID 10000 with administrator privileges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment