Difference between revisions of "Wsl2 vpn fix route"
Jump to navigation
Jump to search
(Created page with "``` Get-NetIPInterface -InterfaceAlias "vEthernet (WSL)" | Set-NetIPInterface -InterfaceMetric 1 Get-NetAdapter | Where-Object { $_.InterfaceDescription -like "PANGP*" } | Set...") |
|||
Line 1: | Line 1: | ||
``` | ``` | ||
+ | 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 | ||
+ | ``` | ||
+ | |||
+ | ``` | ||
+ | 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-NetIPInterface -InterfaceAlias "vEthernet (WSL)" | Set-NetIPInterface -InterfaceMetric 1 | ||
Get-NetAdapter | Where-Object { $_.InterfaceDescription -like "PANGP*" } | Set-NetIPInterface -InterfaceMetric 4000 | Get-NetAdapter | Where-Object { $_.InterfaceDescription -like "PANGP*" } | Set-NetIPInterface -InterfaceMetric 4000 | ||
# Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 4000 | # Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 4000 | ||
``` | ``` |
Revision as of 17:11, 12 August 2024
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
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