Created
January 20, 2023 17:10
-
-
Save rabimba/a1497643662a7ceee0d229974e966d16 to your computer and use it in GitHub Desktop.
AnyConnect DNS resolution fix for WSL2
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
#!/bin/bash | |
echo "Getting current DNS servers, this takes a couple of seconds" | |
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command ' | |
$ErrorActionPreference="SilentlyContinue" | |
Get-NetAdapter -InterfaceDescription "Cisco AnyConnect*" | Get-DnsClientServerAddress | Select -ExpandProperty ServerAddresses | |
Get-NetAdapter | ?{-not ($_.InterfaceDescription -like "Cisco AnyConnect*") } | Get-DnsClientServerAddress | Select -ExpandProperty ServerAddresses | |
' | \ | |
awk 'BEGIN { print "# Generated by vpn-fix on", strftime("%c"); print } { print "nameserver", $1 }' | \ | |
tr -d '\r' > /etc/resolv.conf | |
clear |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment