microsoft / WSL

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

WSL2 - No internet/network on brand new Windows install/etc #7625

Open Dariusz1989 opened 2 years ago

Dariusz1989 commented 2 years ago

Version

10.0.19043

WSL Version

Kernel Version

5.10.16

Distro Version

Ubuntu

Other Software

No response

Repro Steps

I installed Windows 10x64 Pro I did wsl --install That error at some point & I updated kernel > https://docs.microsoft.com/en-gb/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package > WSL2 Linux kernel update package for x64 machines I went back and did wsl --install -d Ubuntu

I've added nameserver to resolve.conf file as 8.8.8.8 and tried a number of different ips.

I've gone over countless of topics on github/etc as to how to "fix" it. Reality is, I cant, I can only downgrade to WSL1 and then I have internet access.

Can this please be fixed?

Expected Behavior

ping www.google.com to return a valid ping.

Actual Behavior

ping: www.google.com: Temporary failure in name resolution

Diagnostic Logs

My network devices > image

No response

scyto commented 2 years ago

try the following:

  1. uninstall hyper-v all of its adapters
  2. netsh int ipv4 reset
  3. netsh int ipv6 reset
  4. re-install hyper-v and all of its adapter

the hosts file fix should never be needed, generally if name resolution stops working i have found it is a corruption in the hosts networking stack, i have given up trying to persuade folks on the DNS thread from hell or Microsoft, i have been telling people about this bug for 2 years....

good luck

scyto commented 2 years ago

just as a note i was getting pings but apt insisted on trying ipv6 and when forced to ipv4 wouldn't contact server. after doing what i said above AND removing wsl and containers from add/remove features and then only using the windows store version of WSL preview i now have WSL working, external DNS resolution working, no need to modify anything

tl;dr after 2 years wsl2/hyperv networking stack still don't play nice with each other

lightify97 commented 2 years ago

@scyto Thanks. I have been banging my head for 4 days on this.

scyto commented 2 years ago

@lightify97 glad I could help, I gave up years ago trying to educate folks that editing the hosts files in WSL isn’t fixing the issue… still all this time later havent figured out a repro, I have a thesis it is caused by build to build upgrades…. @craigloewen-msft any ideas? Next time I have a live repro more than willing to allow a remote debug, but tl;dr there are tons of issues caused by atrophy of wsl / hyper-v networking and it’s been there for 2 years…. Happy to have pm discussion if needed. Apart from that, will slink back into shadows now.

lightify97 commented 2 years ago

@scyto That didn't work for me. Can you elaborate on the exact steps?

craigloewen-msft commented 2 years ago

@scyto we haven't been able to reproduce this problem. If you want to try the latest, please try WSL on the Microsoft Store: https://aka.ms/wslstorepage and see if your problem exists there.

Are you running any VPNs?

lightify97 commented 2 years ago

@craigloewen-msft I tried the store version but doesn't work.

Dariusz1989 commented 2 years ago

@craigloewen-msft How do you test it on your end? I have few adapters as you can see on my picture above & not all of them have internet. How does WSL decide which adapter it will use for the internet to configure for? I haven't had the willpower to dive into it again, will try this weekend.

craigloewen-msft commented 2 years ago

@Dariusz1989 we run WSL on a variety of different machines with different networking configurations, mainly through internal selfhosting and see if any are not able to access the network. WSL uses the vEthernet (WSL) adapter.

Are you able to ping IP addresses? (I'm wondering if this is a DNS resolution failure) image

scyto commented 2 years ago

Hi @craigloewen-msft sorry for delay. I have one repro at the moment and before i touch anything and lose it thought i would reach out.

In this variant I seem to have name resolution, but any external connectivity fails.

root@STUDY:/mnt/c/WINDOWS/system32# curl http://www.microsoft.com -I
^C
root@STUDY:/mnt/c/WINDOWS/system32# ping www.microsoft.com
PING e13678.dscb.akamaiedge.net (104.71.213.161) 56(84) bytes of data.
^C
--- e13678.dscb.akamaiedge.net ping statistics ---
7 packets transmitted, 0 received, 100% packet loss, time 6251ms

This was working, all that has happened is time and series of build to build upgrades. I don't know when it stopped working as I am occasional user of WSL (mostly spend my time in linux docker containers on other machines) This is when i normal tear down all hyper-v and container components, reset all networking with netsh and then re-install hyper-v

Versions

WSL version: 0.50.2.0
Kernel version: 5.10.74.3
WSLg version: 1.0.29
Windows version: 10.0.22533.1001

IP address info in WSL

root@STUDY:/mnt/c/WINDOWS/system32# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 8e:62:be:8c:1d:2e brd ff:ff:ff:ff:ff:ff
3: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 7e:16:8e:c5:56:dd brd ff:ff:ff:ff:ff:ff
4: tunl0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
    link/ipip 0.0.0.0 brd 0.0.0.0
5: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0
6: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1280 qdisc mq state UP group default qlen 1000
    link/ether 00:15:5d:26:06:d5 brd ff:ff:ff:ff:ff:ff
    inet 172.24.245.122/20 brd 172.24.255.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::215:5dff:fe26:6d5/64 scope link
       valid_lft forever preferred_lft forever

netsh dump output (if you want more, let me know)

netsh.dump.txt

scyto commented 2 years ago

if someone wants a remote debug i am fine with that (i live in 98033 so trust you guys ;-) )

mohammedalsayegh commented 2 years ago

I am experiencing the same problem! Even though I re-installed hyper-v and all its adapters, the problem persists. Despite trying to bridge the WSL virtual switch to an external network, the problem did not resolve by bridge.

The problem also occurs with WSA. It seems that they use the same virtual switch. WSA and WSL are capable of interacting with other machines via the internal network.

And, in the case of switching virtual switches to external, an error message is displayed and an override and pre-creation of virtual switches with the same name results in no connections internal and externally. As it result on switching the virtual network switch into private network. So, it seems to be an issue with the virtual switch.

image

ash1khan commented 2 years ago

Working fine until september. Couple of updates from Microsoft and its broken. Banging my head on this for 8 days without any real solution. Tried every single solution from stackoverflow, askubuntu and other various places. nothing worked. WSL1 seems working fine if I downgrade. Time to switch into real Ubuntu OS I guess. Will see if microsoft can solve it in few years.

OS Build version : 10.0.2200 Kernel version : 5.10.81.1 WSL2 @ Ubuntu-20.04 LTS

scyto commented 2 years ago

@AshiquzzamanKhan @mohammedalsayegh in my case the workaround is simple if a PITA - uninstall hyper-v (reboot), reset network with netsh, reinstall hyper-v (reboot).

@mohammedalsayegh that deletion errors doesn't look like its related to this WSL issue, looks like something else IMO as you are getting access denied.

mohammedalsayegh commented 2 years ago

Ok, I found the problem, it seems to be a problem with the last update that caused multiple virtual switches to be created as I didn't create or install anything that creat virtual switches other than WSL and WSA which worked fine. I fixed the issue by deleting all virtual switches in device manger and resetting the network, which caused DNS re-assignment.

So, I turn on hidden devices:

image

Then I deleted all virtual networks, including virtual wifi, that were duplicates:

image

The fix fixes the WSL and WSA networking issue which was great since I wasn't sure what the problem was for last couple days!

I found solution over here: https://gist.github.com/coltenkrauter/608cfe02319ce60facd76373249b8ca6#gistcomment-3443182

I did change namespace in the past which made WSL work for a while. But, it seems everything has been shifted to virtual switch end which reset the namespace in every start. I wish there was more control from the WSL end of how the virtual network starts.

ash1khan commented 2 years ago

@scyto

in my case the workaround is simple if a PITA - uninstall hyper-v (reboot), reset network with netsh, reinstall hyper-v (reboot).

Only Subsystem for Linux and virtual container is installed. No hyper-v ticked. As wsl itself is a self contained hypervisor. Also install via wsl --install flag which only enables two features mentioned above and no hyper-v as per microsoft wsl doesn't require hyper-v enabled. Nonetheless tried enabling disabling that thing. also from hyper-v manager tried altering wsl2 switch from internal to other stuff to see if it works. flushing dns, ip/winsock reset and network reset, .wslconfig swap tricks none of it works. combination of 100 solutions applied. None worked.

scyto commented 2 years ago

The fix fixes the WSL and WSA networking issue

This isn't a fix its a workaround to a bug, i wish folks would stop saying they are fixes, as you noted yourself in the solution you found they break again over time. Only MSFT can fix.....

scyto commented 2 years ago

I wish there was more control from the WSL end of how the virtual network starts.

this wouldn't be needed if MSFT fixes the underlying issue, though i agree more control would be nice :-)

mohammedalsayegh commented 2 years ago

The fix fixes the WSL and WSA networking issue

This isn't a fix its a workaround to a bug, i wish folks would stop saying they are fixes, as you noted yourself in the solution you found they break again over time. Only MSFT can fix.....

You're right, it can't be called a fix. It turns out that you can choose only two out of three options, Hyper V, WSA, and WSL. In order to run WSA and WSL simultaneously, I had to disable Hyper V.

Also, there are some fringe issues after some reboots. In order for WSA to work, DNS must be set manually from time to time in every reboot. Although after yesterday's update, it seems to work fine without Hyper V for WSL and WSA.

cangokdayi commented 2 years ago

try the following:

  1. uninstall hyper-v all of its adapters
  2. netsh int ipv4 reset
  3. netsh int ipv6 reset
  4. re-install hyper-v and all of its adapter

the hosts file fix should never be needed, generally if name resolution stops working i have found it is a corruption in the hosts networking stack, i have given up trying to persuade folks on the DNS thread from hell or Microsoft, i have been telling people about this bug for 2 years....

good luck

In addition to this, you might randomly find yourself in the same situation again. Disabling and re-enabling the Hyper-V WSL adapter in Network Adapter Settings in the old-school control panel should do the trick in case it happens. So you prob don't need to repeat all of these from scratch.

jlecours commented 8 months ago

I was looking into an issue with WSL2 not picking up my DNS and came across this issue. I thought I'd just leave my experience in case it was helpful to others:

I was given a new work laptop that came with Windows 11 on it. In the Windows Features dialog, I do not have Hyper-V (or any child features), Windows Hypervisor Platform, or Windows Subsystem for Linux enabled. Those are all off. I do have Virtual Machine Platform enabled.

I do not have WSL1 installed. I installed WSL2 from an administrative command prompt running wsl --install.

C:\>wsl --version
WSL version: 2.0.14.0
Kernel version: 5.15.133.1-1
WSLg version: 1.0.59
MSRDC version: 1.2.4677
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.2861

From the distribution list (wsl -l -o) I chose to install Ubuntu 22.04 (wsl --install Ubuntu-22.04) and set that as my default distro (wsl -s Ubuntu-22.04).

C:\>wsl --status
Default Distribution: Ubuntu-22.04
Default Version: 2
WSL1 is not supported with your current machine configuration.
Please enable the "Windows Subsystem for Linux" optional component to use WSL1.

WSL2 works for me. I could succesfully get ping responses from IP address but not hostnames. DNS was not automatically working for me. I ended up editing /etc/wsl.conf and /etc/resolv.conf to manually set DNS, which isn't an ideal solution but it works for me:

jlecours@HOSTNAME:/mnt/c$ cat /etc/wsl.conf

[boot]
systemd=true

[network]
generateResolvConf=false

jlecours@HOSTNAME:/mnt/c$ cat /etc/resolv.conf
nameserver 8.8.8.8
chanpreetdhanjal commented 8 months ago

Hi. Can you please collect networking logs by following the instructions below? https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#collect-wsl-logs-for-networking-issues