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.

God-damnit-all commented 4 years ago

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

craigloewen-msft commented 4 years ago

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 commented 4 years ago

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.

God-damnit-all commented 4 years ago

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

awson commented 4 years ago

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 commented 4 years ago

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.

God-damnit-all commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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?

God-damnit-all commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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

aaemon commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

This happened to me after updating to 20206

blackliner commented 4 years ago

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...

dezza commented 4 years ago

@blackliner If you don't already have Hyper-V try installing it via Windows Features. It created the vEthernet (WSL) adapter I supposedly needed, because after removing Hyper-V the adapter remains and networking is still working.

blackliner commented 4 years ago

@blackliner If you don't already have Hyper-V try installing it via Windows Features. It created the vEthernet (WSL) adapter I supposedly needed, because after removing Hyper-V the adapter remains and networking is still working.

Hyper-V was all installed, and is part of the WSL2 prerequs. But what actually helped was this: https://github.com/microsoft/WSL/issues/5336#issuecomment-688347745

dezza commented 4 years ago

@blackliner If you don't already have Hyper-V try installing it via Windows Features. It created the vEthernet (WSL) adapter I supposedly needed, because after removing Hyper-V the adapter remains and networking is still working.

Hyper-V was all installed, and is part of the WSL2 prerequs. But what actually helped was this: #5336 (comment)

Virtual Machine Platform is all WSL2 requires. My problems has returned and I ran netsh resets again. If it returns, I might try installing Hyper-V again and see if it persists longer..

marcmy commented 4 years ago

Went through a bunch of solutions. Nothing worked. Found out the problem was my %temp% folder (C:\Users\username\AppData\Local\Temp) was compressed. I uncompressed it and that fixed it immediately.

daneb commented 4 years ago

I am having the same issue. Box goes into standby and on awake WSL2 network is gone. The Hyper-V settings are the same. I tried:

I have to close all my business applications and their state and do a "Network reset" and reboot. This works flawlessly without any other changes. Is there an emoticon for depression? 😫😯🤐

dezza commented 4 years ago

@daneb Try run cmd.exe as administrator and type

sc stop 'LxssManager'
sc stop 'Host Network Service'

But please try to revert your previous configurations to stock as much as possible first.

On another note; Is anyone aware of a way to reconfigure the interfaces for WSL upon host network change instead of restarting these services? If you reconnect to networks, sometimes its in a unusable state, and it would really be nice to be able to reconfigure it, without shutting all down.

ffpenaloza commented 4 years ago

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.

daneb commented 4 years ago

@daneb Try run cmd.exe as administrator and type

sc stop 'LxssManager'
sc stop 'Host Network Service'

But please try to revert your previous configurations to stock as much as possible first.

On another note; Is anyone aware of a way to reconfigure the interfaces for WSL upon host network change instead of restarting these services? If you reconnect to networks, sometimes its in a unusable state, and it would really be nice to be able to reconfigure it, without shutting all down.

@dezza thanks for the suggestion. I stopped and even shutdown wsl, but nothing. What is LxssManager, and was that not related to WSL 1?

daneb commented 4 years ago

@blackliner If you don't already have Hyper-V try installing it via Windows Features. It created the vEthernet (WSL) adapter I supposedly needed, because after removing Hyper-V the adapter remains and networking is still working.

Hyper-V was all installed, and is part of the WSL2 prerequs. But what actually helped was this: #5336 (comment)

Virtual Machine Platform is all WSL2 requires. My problems has returned and I ran netsh resets again. If it returns, I might try installing Hyper-V again and see if it persists longer..

@dezza I believe WSL2 is based off Hyper-V. Or do I have it wrong?

dezza commented 4 years ago

@daneb currently it only requires Virtual Machine Platform Windows feature. I am unsure if this is directly related to the installable Hyper-V package, but I assume some things are reused - its essentially a stripped down version as I understand.

LxssManager is the primary service for managing WSL distributions. When it is restarted it will setup the link between the host and the client, it is needed when I for example restart my wireless network, or change settings on it. It would be cool if you could avoid shutting down all processes and instead reconfigure the network bridge.

daneb commented 4 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. 😁😍😘🥰

ystxn commented 4 years ago

None of the solutions here worked for me - I've been using WSL2 since 1904 and had no problems whatsoever. Suddenly, I'm experiencing no network today. I recently upgraded to 20H2 (19042.546) but I can't be certain that was the cause.

No network is literal - I cannot even ping my host system from the vEthernet address, let alone any local network devices or Internet addresses or DNS servers.

The only thing that restored network was going back to WSL1, which really defeats the purpose. I'm on a release preview ring rather than slow/fast rings so it is worrying that such major issues reach production status. Is this a known issue with a fix already on its way?

daneb commented 4 years ago

None of the solutions here worked for me - I've been using WSL2 since 1904 and had no problems whatsoever. Suddenly, I'm experiencing no network today. I recently upgraded to 20H2 (19042.546) but I can't be certain that was the cause.

No network is literal - I cannot even ping my host system from the vEthernet address, let alone any local network devices or Internet addresses or DNS servers.

The only thing that restored network was going back to WSL1, which really defeats the purpose. I'm on a release preview ring rather than slow/fast rings so it is worrying that such major issues reach production status. Is this a known issue with a fix already on its way?

@ystan - is your virtual interface for WSL created in Hyper-V Manager? Secondly, can you ping your Windows IP on the same range as your WSL IP? Thirdly, did you do the stop of all 4 services and a start (as mentioned above)?

ystxn commented 4 years ago

is your virtual interface for WSL created in Hyper-V Manager? Yes. Everything looks normal from windows (network adaptors) and within WSL (ifconfig). Hyper-V Switch is correctly set to Internal.

Secondly, can you ping your Windows IP on the same range as your WSL IP? No. It would appear that the vEthernet adaptor / bridge is damaged somehow. Ping fails and I also tried to netcat listen from one side to connect to the other side. What does work is if I mess with the Hyper-V Switch and change it to External, then assign an actual network IP to WSL. I can then communicate with the host via its regular (non-172) IP. I do not believe that is how this is intended to work though.

Thirdly, did you do the stop of all 4 services and a start (as mentioned above)? Yes. I tried the complete steps of resetting all network settings and services, restarting windows many times in the process. I even tried to remove and add back windows components for Virtual Machine Platform, WSL, Hyper V etc. All of them did not help. The only way to make it work as-is was to change back to WSL1.

dezza commented 4 years ago

@daneb No network is literal - I cannot even ping my host system from the vEthernet address, let alone any local network devices or Internet addresses or DNS servers.

Try https://github.com/microsoft/WSL/issues/4288#issuecomment-656991493

ystxn commented 4 years ago

@daneb No network is literal - I cannot even ping my host system from the vEthernet address, let alone any local network devices or Internet addresses or DNS servers.

Try #4288 (comment)

my interfaces also had forwarding disabled like in this post, but enabling forwarding did not help. also tried combining with the resets and service restarts in this post. networking is still broken.

ystxn commented 4 years ago

okay i've resolved my problem in the strangest way - by uninstalling an old cisco anyconnect vpn. this has been on my system for ages (rarely used) with no problems running WSL2 the whole time. not sure what prompted this issue to suddenly occur.

so WSL2 networking is now fully restored - and i note that the interface forwarding is still disabled by default - so it appears that is not required.

tomehb commented 4 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. 😁😍😘🥰

This also worked for me - Thank you!

doterik commented 4 years ago

@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 commented 4 years ago

@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 commented 4 years ago

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 commented 3 years ago

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

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

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 commented 3 years ago

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

lohman commented 3 years ago

@IskanderNovena , you fixed it, thanks!

johanhammar commented 3 years ago

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

sgkoishi commented 3 years ago
❯ 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