In the command prompt:
Method 1. This way, you use the internet in wsl1 and need to swich to wsl2 later.
- wsl -l -v
( NAME STATE VERSION
- Ubuntu-22.04 Running 2)
-
wsl --set-version Ubuntu-22.04 1
-
bash
-
sudo apt-get update
This worked for me.
Method 2. This way you keep using WSL, but need to apply below fixed and still might not work.
Finally made it work in WS2. I am not really sure how i did it. I have pushed all buttons, somehow it worked I guess 🗡
-
Control Panel\System and Security\Windows Defender Firewall -> Advanced Setting -> Outbound Rules, Click new Rule, choose program -> Next -> Select the wsl.exe in system.32 -> Select all profiles -> Save it with a fancy name.
-
WSL settings -> Enable localhost forwarding, and Networking Mode-> VirtioProxy (this can be done via .wslconfig file, needs to be in /Users/%Username% folder)
-
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf sudo chattr +i /etc/resolv.conf # Make resolv.conf immutable
-
sudo ip route del default via 192.168.1.1 dev eth1
-
source ~/.bashrc
-
sudo nano /etc/wsl.conf
-
add
-
[network] generateResolvConf = false 7.sudo ip route add default via 127.0.0.1 dev loopback0
-
wsl --shutdown
At some point I have done this: sudo dhclient -r eth0 sudo dhclient eth0
you can use this command to check your connection speed, if this command works, you are done.
curl -v https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py