First: This is not a duplicate --> I have read and tried about a thousand different answers to similar problems today, but none of them seem to work in my particular case.
Also: I originally posed this on Stackoverflow and was redirected here, thought it's weird cos I found all other related answers on the same site... and those weren't closed. ¯\(ツ)/¯
See:
- https://stackoverflow.com/questions/62314789/no-internet-connection-on-wsl-ubuntu-windows-subsystem-for-linux
- https://stackoverflow.com/questions/66444822/wsl-2-dns-is-not-working-with-vpn-connection-on-win-10
- https://stackoverflow.com/questions/57633406/unable-to-access-network-from-wsl2
- etc.
Context: I'm trying to get an internet connection on WSL2. My setup is a bit weird (more on that in section "I cannot try: ..."), because I'm on a company PC. When I'm at my workstation, I hook up via ethernet cable. However, when I'm mobile or at home, I need to connect to our VPN, in order to gain access to everything internal. We use Cisco Anyconnect as VPN. So far I have been unable to get any connection on WSL2, neither while connected via ethernet, nor while connected via Wifi + VPN.
I have tried (so many things...):
- Disconnecting the VPN, restarting WSL and reconnecting to VPN
- I have tried several different versions of /etc/resolv.conf, notably (but not limited to):
- Adding nameservers
1.1.1.1,8.8.8.8,8.8.4.4. and the<Cisco Annyconnect Interface DNS servers> - Adding the proper search spaces to the file.
- Adding nameservers
- Doing all of the above via the
.bashrcon boot. - Making the
/etc/resolv.conffile immutable - Making the
/etc/resolv.conffile mutable - Making the
/etc/wsl.conffile not rewrite the/etc/resolv.conffile on reboot. - Automating a script that gets the dns servers everytime the wsl client is started and fills the
/etc/resolv.conffile. - Changing a bunch of settings in the "WSL Settings" app, amongst others the network mode, to no avail.
- Changing the Adapter interface metric to something really high.
- Disabling and reenabling WSL Subsystem for Linux
- Uninstalling WSL completely and reinstalling it with a single new clean Ubuntu distro, to make sure it's not something in the machine settings.
- and others I'm probably forgetting... I have been at this for eons!
I cannot try:
Uninstalling Cisco Anyconnect and reinstalling it from store. I'm on a company laptop and I don't have the rights to uninstall it. The Windows store has been completely removed I believe and we use something like a self-built store.
Edit after brief stackexchange discussion: I also can't ask the IT-Department of the company for help, as I'm in the IT department and the only person who could know is sitting opposite me and has no idea either. He's even submitted an official bug-report with Cisco, but hasn't gotten any response (afaik).
Temporary fix:
I have managed to get it running through a mixture of writing a custom /etc/resolv.conf file (with the proper DNS servers and such), and downgrading WSL to version 1. For some reason this works, though it is SOOOO slow. Even sudo apt update takes about 20 seconds to even establish a connection to the mirrors. Additionally this only works on the ethernet connection and not on Wifi with VPN.
In short:
I've tried everything I could find on the internet and I've had no results. I've found an inelegant solution that I'm not happy with and I want to find a proper fix.
Basically I'm this close to throwing my coffee-cup through the screen and I need help.