Skip to content

Instantly share code, notes, and snippets.

@xirixiz
Created February 17, 2021 09:20
Show Gist options
  • Save xirixiz/95a31d924f3ec87f501f9dd2349fba3f to your computer and use it in GitHub Desktop.
Save xirixiz/95a31d924f3ec87f501f9dd2349fba3f to your computer and use it in GitHub Desktop.
# 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