Created
February 17, 2021 09:20
-
-
Save xirixiz/95a31d924f3ec87f501f9dd2349fba3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bram van Dartel: Fix WSL2 network connection after setting up a Cisco Anyconnect VPN. | |
# Boot your laptop, start Docker and WSL2, setup a Cisco Anyconnect VPN connection, run this fix. | |
function Fix-WSLNet { | |
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit } | |
Get-NetIPInterface -InterfaceAlias "vEthernet (WSL)" | Set-NetIPInterface -InterfaceMetric 1 | |
Get-NetAdapter | Where-Object { $_.InterfaceDescription -Match "Cisco AnyConnect" } | Set-NetIPInterface -InterfaceMetric 6000 | |
} | |
Fix-WSLNet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment