Skip to content

Instantly share code, notes, and snippets.

@ek-nath
Created November 4, 2021 19:16
Show Gist options
  • Save ek-nath/c763fa94dc92f82cf3037f134e18b026 to your computer and use it in GitHub Desktop.
Save ek-nath/c763fa94dc92f82cf3037f134e18b026 to your computer and use it in GitHub Desktop.
Cisco Anyconnect WSL DNS fix
echo "Getting DNS nameservers"
$ns = Get-DnsClientServerAddress -AddressFamily IPv4 | Select-Object -ExpandProperty ServerAddresses | %{ "nameserver " + $_;}
echo "Getting search domains"
$sd = Get-DnsClientGlobalSetting | Select-Object -ExpandProperty SuffixSearchList | %{ "search " + $_;}
echo "-----------------------"
echo $ns
echo $sd
echo "-----------------------"
Read-Host -Prompt 'Hit enter after you copy the above text in wsl /etc/resolv.conf'
echo "Changing InterfaceMetric for Cisco Anyconnect"
Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 6000
# get wsl process
$wsl = Get-Process wsl -ErrorAction SilentlyContinue
$continue = "n"
if ($wsl) {
echo "wsl is running. You may want to save any incomplete work before proceeding"
while($continue -eq 'n') {
$continue = Read-Host -Prompt 'Should I restart wsl'
}
}
remove-variable wsl
echo "Restarting wsl"
Restart-Service LxssManager
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment