Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WSL2] No network #4731

Open
awson opened this issue Dec 4, 2019 · 68 comments
Open

[WSL2] No network #4731

awson opened this issue Dec 4, 2019 · 68 comments
Labels

Comments

@awson
Copy link

awson commented Dec 4, 2019

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.

@ImportTaste
Copy link

ImportTaste commented Dec 4, 2019

I'm having the same problem on 19033. This is bizarre.

@craigloewen-msft
Copy link
Member

Are you using a VPN? Or any other kind of networking configuration that could affect it?

And could you please take a networking trace for us and post the feedback item here?

Thanks!

@awson
Copy link
Author

awson commented Dec 4, 2019

I use no VPN and/or any other peculiar networking configuration, at least I've changed nothing since previous days when things were OK.

I've created and sent the feedback according to your link but I don't know what "feedback item" is, and what should I post here (I'm also not logged in and I can't retrieve my feedback then).

I've also checked "Save log data locally" or similar (I don't remember the wording) checkbox but nothing interested happened.

I've looked into C:\ProgramData\Microsoft\Windows\WER\ReportArchive directory and found 3 recently created Critical..... directories (among older ones) with Report.wer file in each, which contain basically only the links to temporary (now gone) files used to create the report.

@ImportTaste
Copy link

Upgraded to 19035 and it seems to magically be working again.

@awson
Copy link
Author

awson commented Dec 5, 2019

Same here. Have just upgraded and it works now.

Are there Wsl 2-related registry (or other config) entries which may be purged completely to have a chance to be rewritten by the healthy ones?

@ricardosantos9521
Copy link

This is happening to me after my pc goes to sleep for long hours. Shutting down wsl2 (wsl.exe --shutdown) and open it again solves the problem until the next time the pc goes to sleep again for long hours.

@ImportTaste
Copy link

ImportTaste commented Dec 8, 2019

Sleep/Hibernate isn't enabled on my machine, though.

I have noticed a lot more free space on my system disk with 20H1, and so I'm wondering if this might have something to do with the compression tech Windows is now using to shrink the size of system files. Perhaps it's touching WSL, or something WSL interacts with.

It hasn't happened to me since the 19035 update, though.

@Biswa96
Copy link

Biswa96 commented Dec 8, 2019

I am using WSL2 in Windows 10 insider build 19035 without any issue. You can check something like -- if eth0 interface present in wsl2, if ping to ip address work, if vEthernet (wsl) present in Windows, if Windows firewall has two inbound rules containing hns string etc. Also add the strace and/event logs as stated here.

@CalBR
Copy link

CalBR commented Dec 11, 2019

I was using build 19033 without problems. Updated to 19037 and my internet stopped working. To be able to use the internet I had to set the nameserver to 8.8.8.8 in the /etc/resolv.conf which solves the connection failure but keeps me from using the X410. Any suggestions?

@ImportTaste
Copy link

@CalBR We're all as confused as to why it randomly breaks as you are, and the tools to try and diagnose it aren't able to gather any useful information.

19041 is out and it might be a good idea to build an iso with https://UUPdump.ml and do an in-place upgrade.

@qqkookie
Copy link

qqkookie commented Dec 19, 2019

I am using Window 10 Insider Beta version 2004 Build 19041.1. I installed latest Ubuntu app from MS App Store. It works fine in WSL version 1.

But after conversion to WSL 2 , network does not work.
Even ping 127.0.0.1 does not work. ( network unreachable )
nslookup result: /../../../lib/isc/unix/net.c:592: probing sendmsg() with IP_TOS=b8 failed: Network is unreachable.

I tried various fix suggested in other threads but they does not work.
It is not DNS problem or /etc/resolv.conf or nsswitch.conf.

TCP/IP network socket just stopped working in WSL 2 on Window 10 Build 19041.
Linux kernel does not recognize network interfaces of PC.
Unix domain socket works fine.

Only working solution is converting back to WSL 1. Then it works fine again.

In attached text file, there is ifconfig -a results on WSL 2 and WSL 1, respectively.

WSL-ifconfig.txt

@rm-bergmann
Copy link

rm-bergmann commented Dec 19, 2019

I have exactly the same problem. No problems with WSL2 on my office PC, only my home PC.
I've also tried all suggested fixes and still unable to get it working. Worst thing for me now is docker desktop stopped working on WSL1 so when I convert back to WSL1 I just get weird input / output errors now. I would rather have WSL2 fixed anyway.

@rm-bergmann
Copy link

Finally I solved my problem. In Hyper-V Manager > Virtual Switch Manager > WSL Adapter, switched to External Network and selected my WIFI network. Inside WSL I gave it a 192.168 IP address which is in the same range as my WIFI network, rather than the 172. range that is generated, and I had to add the 192.168 ip address in /etc/resolv.conf. I still don't know why the NAT / Internal switch doesn't work.

@secopsbot
Copy link

Same problem if/when my laptop hibernates, rebooting is the only thing that currently resolves.

Did you need to do anything before changing the connection type @rm-bergmann when I try to change my WSL Adapter to any External Network I'm getting the error below.

Virtual Switch Manager for secopsbot

Error applying Virtual Switch Properties changes

Adding ports to the switch 'WSL' failed.

The operation failed because the object was not found.

@rm-bergmann
Copy link

rm-bergmann commented Feb 5, 2020

@secopsbot I think I hit that error a few times, then I hat to shut down WSL2 and run Hyper-V as administrator. The annoying thing was I had to repeat the process after every reboot. I also remember I had to right click on the wifi network adapter (in the 'view network connections' windows) and click "Remove from Bridge".

I have since deleted that instance of WSL2, and set up a new one using that same process. I can get network, but now I get the DNS resolving issue.

@twiguard
Copy link

I had the "unreachable" problem when I turned on compression on parts of the C: partition. It solved itself after turning it off again.

@albinkc
Copy link

albinkc commented Apr 28, 2020

I figured it was my VPN [Wireguard]. Worked fine after I disabled it.

@aaemon
Copy link

aaemon commented May 2, 2020

WSL2 worked fine in 19035, But after update to 19041, WSL2 no longer has internet. Although WSL1 working fine. I am not using any VPN, it is just my PC connected via wifi to my router.

@shef
Copy link

shef commented May 5, 2020

I'm observing same problem on 10.0.19041.208. Everything was working yesterday. Today, after hibernate/standby, WSL2 network is down.
I can ping vEthernet from windows:

C:\WINDOWS\system32>ping 172.30.32.1

Pinging 172.30.32.1 with 32 bytes of data:
Reply from 172.30.32.1: bytes=32 time<1ms TTL=128
Reply from 172.30.32.1: bytes=32 time<1ms TTL=128

But I cannot ping it from WSL2, eth0 interface has NO-CARRIER flag:

~$ ip add show dev eth0
5: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 00:15:5d:25:71:f8 brd ff:ff:ff:ff:ff:ff
    inet 172.30.37.116/20 brd 172.30.47.255 scope global eth0
       valid_lft forever preferred_lft forever
~$ ip -4 neigh
172.30.32.1 dev eth0 lladdr 00:15:5d:f5:0c:6e STALE
~$ ping 172.30.32.1
PING 172.30.32.1 (172.30.32.1) 56(84) bytes of data.
^C
--- 172.30.32.1 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1076ms

Tried to flap the port on both sides (windows and WSL) - didn't help. Any workarounds other than restart Windows or WSL2?

@evilhamsterman
Copy link

Same here, I just reset my Windows 10 installation after a motherboard upgrade and was unable to install any WSL instances as new version 2 instances. Got them installed as version 1 instances and then was able to convert them to version 2 and none of them have working networking in version 2.

@Marietto2008
Copy link

I've installed ubuntu 20.04 on WSL2 and I started a VM with qemu and kvm,running mac os x as guest os. It works great,except for the configuration of the net. Infact it is not able to connect to internet. Sometime from WSL I get a 192.x.x.x ip number,like :

192.168.69.65 ; 192.168.71.185 ; 192.168.73.223 ; 192.168.69.33 ; 192.168.100.101

sometime I get a 172.x.x.x ip address,like : 172.22.250.54 ; 172.22.253.128 ; 172.21.138.120 ; 172.22.88.142.

The vEthernet (WSL) adapter on Windows 10 is configued like this : 172.26.80.1 as IP address,subnet mask = 255.255.240.0

I have created a bridge in WIndows 10,between my Intel ethernet adapter and the tap0 / Tap-windows. It's IP is 192.168.1.6 ; subnet mask = 255.255.255.0 ; gateway = 192.169.1.1 ; dns primary = 8.8.8.8

In WSL2 I have configured th network like this :

root@DESKTOP-N9UN2H3:/mnt/c/Android/sdk/platform-tools# brctl addbr br0
root@DESKTOP-N9UN2H3:/mnt/c/Android/sdk/platform-tools# ip addr flush dev eth0
root@DESKTOP-N9UN2H3:/mnt/c/Android/sdk/platform-tools# brctl addif br0 eth0

root@DESKTOP-N9UN2H3:/mnt/c/Android/sdk/platform-tools# tunctl -t tap0 -u root
Set 'tap0' persistent and owned by uid 0

root@DESKTOP-N9UN2H3:/mnt/c/Android/sdk/platform-tools# brctl addif br0 tap0
root@DESKTOP-N9UN2H3:/mnt/c/Android/sdk/platform-tools# ifconfig eth0 up
root@DESKTOP-N9UN2H3:/mnt/c/Android/sdk/platform-tools# ifconfig tap0 up
root@DESKTOP-N9UN2H3:/mnt/c/Android/sdk/platform-tools# ifconfig br0 up

root@DESKTOP-N9UN2H3:/mnt/c/Android/sdk/platform-tools# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.00155d99cfa4 no eth0
tap0

root@DESKTOP-N9UN2H3:/mnt/c/Android/sdk/platform-tools# dhclient -v br0

Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/br0/00:15:5d:99:cf:a4
Sending on LPF/br0/00:15:5d:99:cf:a4
Sending on Socket/fallback
DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 3 (xid=0xbbd3b615)
DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 8 (xid=0xbbd3b615)
DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 12 (xid=0xbbd3b615)
DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 11 (xid=0xbbd3b615)

root@DESKTOP-N9UN2H3:/mnt/c/Android/sdk/platform-tools# ifconfig

br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::215:5dff:fe99:cfa4 prefixlen 64 scopeid 0x20
ether 00:15:5d:99:cf:a4 txqueuelen 1000 (Ethernet)
RX packets 172 bytes 43127 (43.1 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 16 bytes 2304 (2.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether 00:15:5d:99:cf:a4 txqueuelen 1000 (Ethernet)
RX packets 543 bytes 121055 (121.0 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 28 bytes 3280 (3.2 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
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

tap0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 46:88:cb:85:5f:9e 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

root@DESKTOP-N9UN2H3:/mnt/c/Android/sdk/platform-tools# ping www.google.it
ping: www.google.it: Name or service not known

I think IPv4 issue can be solved with configuring DHCP, but I don't know how to do that. I dont know why after removing address from eth0, which had an ipv4 address, and creating a bridge,it becomes no ipv4.

@dezza
Copy link

dezza commented Sep 6, 2020

This happened to me after updating to 20206

@blackliner
Copy link

me 2, almost no more connectivity. Sporadic something works.

I had to update realtek nic drivers because of some sleep/resume device error, no idea if that relates...

@tomehb
Copy link

tomehb commented Oct 11, 2020

@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. 😁😍😘🥰

This also worked for me - Thank you!

@doterik
Copy link

doterik commented Oct 28, 2020

@daneb

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

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

Then start them back up again.

Only thing that worked for me, at least this time... Thanks.

Depression has ended. 😁😍😘🥰

@kensleDev
Copy link

kensleDev commented Oct 29, 2020

@ffpenaloza

I had this problem for months, but finally I solved it in one step, 1 second.
I did not have the directory C:\Users[username]\AppData\Local\Temp for some reason... So I just navigated to C:\Users[username]\AppData\Local, created the Temp folder, run the wsl --shutdown command in PowerShell and voilà... magic.
I hope it can help someone.

I was so close to giving up... this worked for me after attempting this maybe 5 times.

Thanks 🥰

@ghost
Copy link

ghost commented Nov 12, 2020

I had same issue after windows update, wsl --shutdown fixed it right up. After restarting WSL, network was back up and running.

Spent severals hours working on this, thanks, this was great help!

@lukee1234
Copy link

If you modified, moved or compressed the temp folder, look at #5437 for the solution

@IskanderNovena
Copy link

@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. 😁😍😘🥰

So far restarting the services seem to work. I've put it together in a self-elevating powershell=script:

if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process (Get-Process -Id $PID | Select-Object -ExpandProperty Path) "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }

Write-Output "Shutting down WSL..."
wsl --shutdown

Write-Output "Stopping services..."
Stop-Service cmservice
Stop-Service hns
Stop-Service vmcompute
Stop-Service lxssmanager

Write-Output "Starting services..."
Start-Service lxssmanager
Start-Service vmcompute
Start-Service hns
Start-Service cmservice

Write-Output "DONE!"
Read-Host "Press ENTER to continue..."

@maximmasiutin
Copy link

Thank you very much, @IskanderNovena! That PowerShell script really helped!

@lohman
Copy link

lohman commented Apr 3, 2021

@IskanderNovena , you fixed it, thanks!

@johanhammar
Copy link

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

@sgkoishi
Copy link

sgkoishi commented Apr 6, 2021

❯ ip add show dev eth0
4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:15:5d:5b:e9:a2 brd ff:ff:ff:ff:ff:ff
    inet 172.18.80.186/20 brd 172.18.95.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::215:5dff:fe5b:e9a2/64 scope link
       valid_lft forever preferred_lft forever

❯ ip route
default via 172.18.80.1 dev eth0
172.18.80.0/20 dev eth0 proto kernel scope link src 172.18.80.186

❯ ipconfig
Ethernet adapter vEthernet (WSL):

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::3dd9:ecd2:9e6d:e5e5%158
   IPv4 Address. . . . . . . . . . . : 172.18.80.1
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . :
ping from 172.18.80.1(Windows) from 172.18.80.186(WSL)
to 172.18.80.1(Windows) <1ms Packet Loss
to 172.18.80.186(WSL) <1ms <1ms
to 8.8.8.8 OK Packet Loss

%temp% is not compressed, Windows 10 20H2 (19042.906), no Cisco or Wireguard or other VPNs
Tried reboot WSL and/or Windows and restart services. Sometimes it works after Windows reboot but not always - not sure which step did the magic.

One potential magic that works (at least once):
Restart service script - HyperV Switch set to private and then set to internal back - Enable network sharing to vEthernet(WSL) for network adapter - Enable forwarding - Reboot Windows

@IskanderNovena
Copy link

@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
Copy link

johanhammar commented Apr 6, 2021

@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
Copy link

@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
Copy link

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

@rhymeswithmogul
Copy link

rhymeswithmogul commented May 28, 2021

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
Copy link

willeccles commented Jun 10, 2021

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: neovim/neovim#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
Copy link

bersbersbers commented Jun 14, 2021

@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
Copy link

kreczko commented Jun 15, 2021

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
Copy link

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
Copy link
Member

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

Instructions here: #7141 (comment)

@ghost
Copy link

ghost commented Jul 9, 2021

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
Copy link

@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
Copy link

@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
Copy link

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
Copy link

SharkyND commented Jan 3, 2022

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

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

@lwbaqueros
Copy link

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

@disberd
Copy link

disberd commented Aug 3, 2022

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
Copy link

Experiencing the same issue on Windows 11 build 22000.978. 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:

  • Disable every network interface (Wi-Fi, VPNs) except the interface I want Hyper-V to use (Ethernet)
  • netsh int ip reset, netsh winsock reset
  • Uninstall Hyper-V, WSL and any related components, reboot, reinstall components

Workaround:

  • Disable every network interface except the PCIe Wi-Fi card
  • Connect to a Wi-Fi network

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests