Wsl2 vpn fix route
Jump to navigation
Jump to search
Get-NetIPInterface -InterfaceAlias "vEthernet (WSL)" | Set-NetIPInterface -InterfaceMetric 1 Get-NetAdapter | Where-Object { $_.InterfaceDescription -like "PANGP*" } | Set-NetIPInterface -InterfaceMetric 4000 # Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 4000
Set routes to default gateway
route add 0.0.0.0 MASK 0.0.0.0 10.x.x.1 route add 172.24.192.0 MASK 255.255.240.0 10.x.x.1
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { # Re-launch the script with elevated privileges $arguments = "& '" + $myInvocation.MyCommand.Definition + "'" Start-Process powershell -Verb runAs -ArgumentList $arguments exit } Get-NetIPInterface -InterfaceAlias "vEthernet (WSL)" | Set-NetIPInterface -InterfaceMetric 1 Get-NetAdapter | Where-Object { $_.InterfaceDescription -like "PANGP*" } | Set-NetIPInterface -InterfaceMetric 4000 # Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 4000