microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.46k stars 822 forks source link

[WSL2] No network #4731

Closed awson closed 7 months ago

awson commented 4 years ago

Microsoft Windows [Version 10.0.19025.1]

Any network activity from inside WSL2 ends up with:

../../../../lib/isc/unix/net.c:592: probing sendmsg() with IP_TOS=b8 failed: Network is unreachable
;; connection timed out; no servers could be reached

ifconfig -a reports:

bond0: flags=5122<BROADCAST,MASTER,MULTICAST>  mtu 1500
        ether 2e:fb:1b:47:93:0a  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

dummy0: flags=130<BROADCAST,NOARP>  mtu 1500
        ether 8a:4f:89:cc:4f:f8  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 00:15:5d:f5:b7:63  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=8<LOOPBACK>  mtu 65536
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

sit0: flags=128<NOARP>  mtu 1480
        sit  txqueuelen 1000  (IPv6-in-IPv4)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vEthernet (WSL) adapter is present and enabled and reports no problems.

It all worked fine till today. Today it stopped working with absolutely no apparent reason. No installations, no updates ...

I tried everything except reinstalling the whole system (which apparently I won't do, since I'll install release if decide to remove insider's), nothing helps.

IskanderNovena commented 3 years ago

@johanhammar

The powershell solution looks cool but unfortunately running scripts on my system is disabled. Any other workarounds available, except rebooting?

You probably don't have administrative rights, which means none of the workaround will work for you. Adding routes and restarting services both need admin-rights.

johanhammar commented 3 years ago

@johanhammar

The powershell solution looks cool but unfortunately running scripts on my system is disabled. Any other workarounds available, except rebooting?

You probably don't have administrative rights, which means none of the workaround will work for you. Adding routes and restarting services both need admin-rights.

It's a policy that prevents scripts from being executed. So the workaround won't work for us.

IskanderNovena commented 3 years ago

@johanhammar

The powershell solution looks cool but unfortunately running scripts on my system is disabled. Any other workarounds available, except rebooting?

You probably don't have administrative rights, which means none of the workaround will work for you. Adding routes and restarting services both need admin-rights.

It's a policy that prevents scripts from being executed. So the workaround won't work for us.

In that case you could run the commands in a PowerShell-prompt, except for the first line (the one starting with if). You'd have to start an elevated prompt manually, though. If your company does allow signed scripts, you could see if you can make a signed version of the script, but that is beyond the scope of this issue. Google will be your friend for that, or your own support staff.

joshfactorial commented 3 years ago

It was firewall for me. My VPN allowed WSL1, but not WSL2.

rhymeswithmogul commented 3 years ago

I'm having this issue as well. I converted a working WSL v1 instance into a WSL v2 instance. Now I have no networking. Bringing eth0 up has no effect, nor does changing the Hyper-V switch from internal or private to external.

Ubuntu 20.04 running on Windows 10 Version 21H1.

willeccles commented 3 years ago

I have a potentially interesting finding. On my end, it appears that after failing to resolve a host (I can confirm that the host doesn't work both on the WSL instance and on Windows itself, but the others do), it will fail to resolve anything else. In my case, this happened when I was trying to build neovim, which downloads libraries from the internet. When www.leonerd.org.uk fails to work (this also fails on WIndows: https://github.com/neovim/neovim/issues/14764), the following lookups for github.com all fail, while github.com works on Windows. If I log into WSL and ping github.com, then ping the failing URL, then try to ping github.com again, it will not work.

Edit: the last sentence does not hold true if I change to another DNS server in /etc/resolv.conf. This is some very interesting behavior.

bersbersbers commented 3 years ago

@willeccles there is a bunch of related issues on DNS resolution in WSL(2), some of which are indeed contaminated by different network issues - anyway, I believe this issue here is about network connectively overall, including being able to access a DNS server in the first place. So maybe your comment would be best placed in other issues.

kreczko commented 3 years ago

Ubuntu 18.04 and 20.04 (i.e. all WSL distributions) do not have any network connectivity (not even localhost). It seems the network interface for WSL is gone. Host network is working fine.

OS Name Microsoft Windows 10 Pro Version 10.0.19043 Build 19043

Virtualization-based security Running Virtualization-based security Required Security Properties
Virtualization-based security Available Security Properties Base Virtualization Support Virtualization-based security Services Configured
Virtualization-based security Services Running
A hypervisor has been detected. Features required for Hyper-V will not be displayed.

janfrederik commented 3 years ago

No connectivity from wsl2 to the internet after Windows update KB5003537 was applied automatically last night. I uninstalled the update and everything working fine again.

craigloewen-msft commented 3 years ago

@janfrederik if you're seeing this from the latest update could you please collect networking logs and post them to this Github issue: https://github.com/microsoft/WSL/issues/7141

Instructions here: https://github.com/microsoft/WSL/issues/7141#issuecomment-874917153

ghost commented 3 years ago

sc stop cmservice

sc stop hns

sc stop vmcompute

sc stop lxssmanager

Do I have to write that cmd, powershell or wsl?

P.S. Oh right I tried it in powershell and it worked. Thanks.

janfrederik commented 3 years ago

@janfrederik if you're seeing this from the latest update could you please collect networking logs and post them to this Github issue: #7141

@craigloewen-msft Yesterday I installed the "2021-07 Cumulative Update for Windows 10 Version 20H2 for x64-based Systems (KB5004945)" and had no problems afterwards. So it seemed to be specific to KB5003537 (which is part of KB5004945 because Windows Update does not suggest it anymore?).

LOuroboros commented 3 years ago

@dezza I resolved my issue in the context of your answer:

Container Management Service needed to be shutdown first. This is working for a re-jolt of the networking in WSL2 from suspend mode.

# sc stop cmservice
# sc stop hns
# sc stop vmcompute
# sc stop lxssmanager

Then start them back up again.

Depression has ended. šŸ˜šŸ˜šŸ˜˜šŸ„°

Thank you very much, this worked perfectly on my end!

I didn't need to restart the cmservice though. I actually don't even have it in my copy of Windows.

Just stopping hns, vmcompute, lxssmanager and then starting them again using sc start worked wonderfully!

Wolvverine commented 2 years ago

WSL2 has network, startup and installation issues - solution:

Disable encryption and file compression: for %TEMP%- the swap file there by default location Or specify where to save in %USERPROFILE%\.wslconfig and disable there:

[wsl2]
...
swapFile = E:\\Temp\\swap.vhdx
...

Disable encryption and compression on directories with distributions:

%appdatalocal%\Packages\CanonicalGroupLimited.Ubuntu*
%appdatalocal%\Packages\TheDebianProject.DebianGNULinux* 
SharkyND commented 2 years ago

https://gist.github.com/mandeepsmagh/f1d062fc59e4e6115385c2609b5f0448

This works like a charm. Just had to set the servername according to the wifi gateway

lwbaqueros commented 2 years ago

check this solution. It worked for me after trying all the above suggestions. Answer here.

disberd commented 2 years ago

Just leaving another potential solution when all solutions telling you to change resolv.conf and adding nameservers do not work. I have been trying to fix internet not working when behind corporate VPN for a long time without any success. After seeing some answers over the internet suggesting to use wsl-vpnkit I confirm that following the approach in https://github.com/sakai135/wsl-vpnkit I finally managed basically effortlessly to have internet connectivity in wsl2 even when over corporate VPN

Edit: I just verified that I actually need both solutions for the system to work. I need to have the correct nameservers (the ones from my corporate network to have connectivity when behind VPN, and also some generic ones like google's dns as fallback for having it work outside of the VPN) on resolv.conf but I also need to enable the wsl-vpnkit as above otherwise I still can't connect to the internet.

alexrsagen commented 2 years ago

Experiencing the same issue on Windows 11 build 22000.978 (edit: still happening on 22621.1413). I have isloated the problem and found a (bad) workaround. The issue is that the Hyper-V Default Switch used for WSL2 NAT networking selects/uses the wrong uplink interface, consistently.

In addition to a few different VPN interfaces (not relevant), I primarily use the on-board Ethernet interface for networking. I also have a PCIe-connected Wi-Fi card installed, which WSL2 consistently uses as the uplink interface for reasons unknown to me.

List of things I have attempted which made no difference at all and did not solve the issue:

Workaround:

It is surprising to me that there is no option to select desired uplink network interface for the Hyper-V Default Switch or NAT solution. This would solve the issue.

microsoft-github-policy-service[bot] commented 7 months ago

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!

alexrsagen commented 7 months ago

I am still experiencing the issue exactly as described. I'm sure many others also are. This issue should not be closed.