...
Code Block |
---|
$ cat /etc/resolf.conf # This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf: # [network] # generateResolvConf = false nameserver 172.17.192.161 |
1. cd /etc
2. echo "[network]" | sudo tee wsl.conf
3. echo "generateResolvConf = false" | sudo tee -a wsl.conf
4. wsl --terminate Ubuntu #(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).
6.5 Connect to your vpn
7. In windows cmd, with the vpn connected do:
> ipconfig /all to get the dns primary and secondary.
135.5.25.53
135.239.25.53
8. With the dns primary and secondary . Replace X.X.X.X in the folllowing steps with the primary and secondary DNS ips
9. echo "nameserver X.X.X.X" | sudo tee resolv.conf (Create resolv.conf and append the line.)
10. echo "nameserver X.X.X.X" | sudo tee -a resolv.conf (Append the line in resolv.conf)
11. wsl --terminate Ubuntu (Terminate WSL in Windows cmd, in case is Ubuntu not Debian).
12. sudo chattr +i /etc/resolv.conf
13. And finally in windows powershell with Administrative rights:
Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 6000
References
Reference | URL |
---|---|
Fix DNS resolution in WSL2 | https://gist.github.com/coltenkrauter/608cfe02319ce60facd76373249b8ca6 |