Created
May 15, 2021 14:28
-
-
Save piyusht007/d83167da42c2e12dfb2a3d0d4d2c066b to your computer and use it in GitHub Desktop.
WSL VPN Fix
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
# Add below function to the ~/.bashrc file to make it available globally | |
vpn_fix () { | |
# Get the DNS servers from windows and add then to the /etc/resolv.conf | |
powershell.exe -Command 'Get-DnsClientServerAddress -AddressFamily ipv4 | Select-Object -ExpandProperty ServerAddresses' | awk 'BEGIN { print "# Generated by vpn fix func on", strftime("%c"); print } { print "nameserver", $1 } END { print "search", "nuance.com" }' | tr -d '\r' | tee /etc/resolv.conf | |
echo "/etc/resolv.conf re-written!!" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Issue Description:
While connecting to VPN the /etc/resolv.conf in WSL distro is upadated with reverse order of DNS IPs, This shell function resets the order and make it identical with the Windows.