Skip to content

Instantly share code, notes, and snippets.

@Lushiane
Lushiane / wsl-vpn-fix.sh
Created September 20, 2021 20:58 — forked from MatMercer/wsl-vpn-fix.sh
Fix WSL 2 DNS resolution when connected to Cisco AnyConnect VPN
#!/bin/bash
#--------------------------------------------------------------------------------#
# #
# Fix WSL DNS resolution with Cisco AnyConnect #
# #
# ! Don't forget to set this configuration in /etc/wsl.conf: #
# [network] #
# generateResolvConf = false #
# #
# Based on: #
@Lushiane
Lushiane / fix-wsl2-dns-resolution
Created August 2, 2021 17:55 — forked from coltenkrauter/fix-wsl2-dns-resolution
Fix DNS resolution in WSL2
More recent resolution:
1. cd ~/../../etc (go to etc folder in WSL).
2. echo "[network]" | sudo tee wsl.conf (Create wsl.conf file and add the first line).
3. echo "generateResolvConf = false" | sudo tee -a wsl.conf (Append wsl.conf the next line).
4. wsl --terminate Debian (Terminate WSL in Windows cmd, in case is Ubuntu not Debian).
5. cd ~/../../etc (go to etc folder in WSL).
6. sudo rm -Rf resolv.conf (Delete the resolv.conf file).
7. In windows cmd, ps or terminal with the vpn connected do: Get-NetIPInterface or ipconfig /all for get the dns primary and
secondary.