Open sbhatti534602210 opened 3 years ago
Change the nameserver sudo nano /etc/resolv.conf '# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/resolv.conf '# [network] '# generateResolvConf = false nameserver xxx.xx.xx Change the name server to 8.8.8.8 and save the file. You should now be able to connect to the internet. -even restarted ubuntu, same error after restarting and the nameserver seems to be reset to default
As you can see from the comment, you should edit the /etc/wsl.conf
to include the following:
[network]
generateResolvConf = false
to prevent /etc/resolv.conf
to be reset.
I'm not an expert, but I think resolv.conf does not play a role here, since resolv.conf is used only for resolving DNS names. If pinging 8.8.8.8 (Google DNS server) directly does not work, then the issue is elsewhere. Do you use a VPN? I think there is an ongoing issue with VPN vs WSL2
Thank you, @patrick330602 and @markko1-pro for getting back to me. So should I edit the /etc/wsl.conf file?
I do not use VPN. I'm using wsl2.
So should I edit the /etc/wsl.conf file?
Yep
Thank you, @patrick330602. I edited /etc/wsl.conf to add the lines:
[network] generateResolvConf = false
I then edited the /etc/resolv.conf to change the name server from the default :
nameserver 8.8.8.8
Closed Ubuntu, reopened it tried:
ping 8.8.8.8
and got:
ping: connect: Network is unreachable
As I understand Ubuntu should be ready to go once you install it and you should not have to edit config files. However, for me, it has not and I don't know why. And also, despite editing the config files, I still cannot connect to the internet from the WSL.
One other thing you could try - disable your antivirus for a while and see whether it helps. I had a similar problem with Kaspersky antivirus. Thankfully our IT allowed me to remove this curse from my PC :)
Thank you, @markko1-pro. I did try that already as it seemed the most likely problem. However, it didn't make a difference.
I had just previously installed Ubuntu and did have connection to the internet in order to download and install packages. However, my computer crashed and I had to do a factory reset. It's after this that I have not been able to connect to the internet from the wsl. I reinstalled, then uninstalled and reinstalled Ubuntu but the problem remains.
My first thought was that it might be the firewall, my computer seems to come with a preinstalled (temporary licence) antivirus software. It had previously expired and I had removed it but with resetting the computer, it got reinstalled.
Regardless of that, I did try the steps I listed above several times, in different orders in case that made a difference. But it doesn't.
By the way, while this problem relates to an Ubuntu installation, I did also try a different wsl distribution, Kali. Which when you download and install from the Microsoft Store comes without any packages. When I tried: sudo apt update I got a network error there as well.
Until 2 days ago it worked normally, but from one moment to another the internet connection in wsl2 was blocked and I no longer have an internet connection. However, I connected the internet to my pc from another provider and if I can have an internet connection in ubuntu. But with the other internet provider I have no connection in ubuntu.
@grovertb All networking utilities, including ping from systemd based distros (Ubuntu, Debian,Fedora,Suse) assume that the network stack is built around 2 services systemd-networkd for links configuration and systemd-resolved for name resolution. If these services failed to start or don't function correctly there is no chance to have networking functional. Could you try networkctl and resolvectl in both cases as a networking "smoke test"? Both services have very flexible configurations and autoconfiguration mechanisms to ensure stable networking via any infrastructure but leave resolve.conf out-of-the-game.
If you're seeing this issue, could you please collect networking logs and post them here in this thread?
Instructions here on how to collect these. Thanks!
Could be related to this bug: https://github.com/microsoft/WSL/issues/7135
I suppose that WSL provides eth0 interface to the distro in the way that is independent from Internet provider. But every ISP use its own hardware and software to connect end-machine to the global infrastructure. If network interface is swon as routable by the networkctl and resolved has sufficient DNS configuration - designated DNS is reachable then WSL does its job well but some Linux configuration is missed or can't be autoconfigured. The issues on the ISP side are also possible. MTR utility helps to know how far your can reach through the WSL VM-Host-Router-... Service provider chain.
@craigloewen-msft, is that directed at me or to @PavelSosin-320 / @grovertb? Can you help with the issue I have raised? Thanks.
@sbhatti534602210 that comment is to anyone who is seeing this issue where you've upgraded your Windows version and your network stops working in WSL. Collecting those logs will help us resolve this issue!
To my understanding your issue is the same as the above, so collecting logs and posting them here is the best way for us to look into this.
Thank you @craigloewen-msft I followed the instructions from Step 8, Collect WSL logs. There is no log file. It just collected a screenshot of what I did. I guess the information is automatically sent via the Feedback Hub. Or do I need to run wpr -start wsl.wprp -filemode?
@sbhatti534602210 The network stack of Ubuntu and other "mature" Linux distros is built around the 2 systemd driven services: systemd-networkd and systemd-resolved. Both services have self-documented configuration files in /etc/systemd/ folder and use the autoconfiguration mechanism. The networkctl and resolvectl allow interactive configuration and testing networking and name resolution instantly. If networkctl sees eth0 (internet) interface as "routable" then WSL provides a network to WSL VM and the internet is accessible. Otherwise, either there is a bug in the WSL Network switch or internet access is blocked by security or eth0 provisioning takes too long and ends with a timeout. In the case of routing via VPN, some additional WSL Kernel features (TUP/TAN support) may be needed or only additional configuration to make the Linux networking stack working.
@benhillis The prove that WSL networking is OK and the root cause is outside WSL: systemctl status NetworkManager ● NetworkManager.service - Network Manager Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2021-07-07 07:55:50 IDT; 5h 34min ago Docs: man:NetworkManager(8) Main PID: 101 (NetworkManager) Tasks: 3 (limit: 9543) Memory: 7.8M CGroup: /system.slice/NetworkManager.service └─101 /usr/sbin/NetworkManager --no-daemon
Jul 07 07:55:50 MSI-wsl NetworkManager[101]:
Context:
systemd-genie is used as an init system
no VPN
Norton internet security is on
Broadband WiFi router
Fedora remix distro
Thank you @PavelSosin-320. I'm sorry, from your message I did not understand what I need to do that I have not done already. Can you specify? Thanks
Hello, same issue here. WSL2 reinstalled from scratch, Ubuntu (tried ArchLinux as well) freshly installed, run wsl and I get
/etc/resolv.conf
ip address
shows that eth0
as down.roberto@WoT:~$ ip address 1: lo:mtu 65536 qdisc noop state DOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: bond0: mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 86:e6:ce:f6:ac:34 brd ff:ff:ff:ff:ff:ff 3: dummy0: mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 1e:fe:2b:f1:3e:4a brd ff:ff:ff:ff:ff:ff 4: eth0: mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 00:15:5d:ca:74:7f brd ff:ff:ff:ff:ff:ff 5: tunl0@NONE: mtu 1480 qdisc noop state DOWN group default qlen 1000 link/ipip 0.0.0.0 brd 0.0.0.0 6: sit0@NONE: mtu 1480 qdisc noop state DOWN group default qlen 1000 link/sit 0.0.0.0 brd 0.0.0.0
and /etc/resolv.conf
shows:
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf: # [network] # generateResolvConf = false nameserver 172.18.128.1
It used to work with 1903 and 1909 if I remember correctly.
I checked that as well and apparently systemd is not even used:
roberto@WoT:~$ systemctl status NetworkManager System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down
Hi Saira. 1). You may use WiFi router running OpenWRT Linux OS that can work as a proxy DNS service by itself but has its own flexible and effective configuration. Its IP 192 .168.1.1 can be used as a primary DNS with under 2ms response time. 2). If you run WSL distro with enabled systemd its resolved service has its own very flexible configuration and autoconfiguration features that allow improvement in security and performance via negotiation with global DNS services and smart, quality-based caching of results. 3. Every Global DNS service 8.8.8.8, 9.9.9.9 offers different privacy agreements and secure protocol support. The nearest deployed instance is just a few miles from your location, i.e. "over the street" response time. Systemd's resolvectl util provides quality info about "probed" DNS's.
@PavelSosin-320 (and a few others), this issue is about ping 8.8.8.8
(and most likely, any other IP) not working - this will most likely not be solved by changing DNS servers. (If ping 8.8.8.8
did work, but name resolution did not, then DNS server mights help, but that would be #4275 or #5256.)
The "secret" place of Windows 10 configuration in the registry you can see in the attachment. It is the partial analog of the Linux resolved.conf I suppose that Chrome and Chromium-based Edge use it. I have no idea whether WSL without systemd can use it. It can contradict the Company's security policy!!!
Addendum: if I set WSL to use version 1 (wsl --set-default-version 1
) and download Ubuntu 18.04, it works fine, I have the network. Trying 20.04, it does not even install from the Store. Why is there another /init
(in addition to /sbin/init
which is linked to systemd
)?
@keltia WSL1 uses Windows network stack, WSL2 has its own network stack - this is the difference. You don't need another init because all WSL distro based on mature Linux distros either use special scripts (Ubuntu) installed with the distro or have the corresponding systemd-genie package that boots and login system using systemd. Not all WSL distros in the MS Store are of the same quality. Ubuntu 20.04 is not more valuable than 18.04 because the current maintained Ubuntu version is 20.10. Almost all valuable Ubuntu packages are in the 20.10 repository today. I have no idea why MS keeps 18.04. Maybe, because it is LTS and still supported by Canonical.
@PavelSosin-320 my point is that I don't understand why it makes such a difference, it was definitely working in WSL2 a few months ago now it doesnt. Switching to WSL1 (which I didn't run before) makes it work, I'm puzzled.
@keltia WSL1 and WSL2 use different networking stack because WSL2 VM uses its own Linux Kernel. Linux networking is provided by the Linux Kernel (keep it updated using wsl --update!!!) and several Linux services heavily dependent on the Kernel version capability and distro's version. These Linux packages are the most frequently updated part of Linux in our days due to fast infrastructure changes and security requirements. Windows 11 is a good example of poor reaction on Internet infrastructure changes. WSL1 has no own Linux Kernel and uses Windows networking stack. It changes very slow and today it lags many years behind the current Internet infrastructure state of technology. Microsoft upgraded Windows networking to offer Microsoft 365 but left WSL2 behind.
I just did the same as keltia and the results were very poor: I got my ISP's DNS - the rust piece of iron maintained occasionally with regular long downtimes and hours long synchronisation lag. It doesn't support the basic security features except "antivirus" for extra money. The communication cost of using GoogleDNS, Cloudfare or Quad9 is neglectable for me.
In addition: I just configure my Win 11 to use Quad9 IPV6 as primary IPV6 DNS and Cloudfare IPV6 DNS as alternative IPV6 DNS. My browsers are cruising! The current WSL Kernel passes IPV6 OK: test -f /proc/net/if_inet6 && echo "Running kernel is IPv6 ready" Running kernel is IPv6 ready -no work is needed here.
@PavelSosin-320, I am not using Wifi on my computer, it's ethernet. @keltia, I also do not understand this. It should just work after installation without having to specifically configure and reconfigure files.
@sbhatti534602210 Did you check that your local network is IPV6 enabled and capable? The are several Web sites that check it, only put https://ipv6-test.com/speedtest/ in your browser. This site checks all aspects of IPV6 connectivity and gives the score. The score must be as close as possible to 20. If some features are shown as unsupported you have no chance to use IPV6. You also shall choose DNS a good DNS service: 1.1.1.1,8.8.8.8,9.9.9.9 that supports all IPV6 DNS features. Anyway, consult in the DNS provider portal about IPV6 support in your region. The DNS provided by ISP's or the company's infrastructure may support IPV6 name resolution or name resolution via secure IPV6-based protocol partially. Check that IPV6 is enabled for the LAN adapter in use. The basic test that ensures IPV6 functionality is execution nslookup Azure.Microsoft.com . It must return both IPV4 and IPV6 addresses. Otherwise, you can miss servers and sites that serve only IP4 or IPV6. Successful ping these addresses from the Windows command line and Linux prompt shows that both IPV6 name resolution, IPV6, and IPV4 networking are fully enabled. IPV6 can be blocked by the Windows network adapter, router, Local network infrastructure, ISP, or DNS. Nothing "just working" in networking today because it is a content delivery channel including content streaming - Netflix, Youtube, Zoom, TVoverIP, Microsoft365!
It may be IPV6 issue if IPV6 is fully enabled in the Networking stack, like in Win 11 & Broadband internet. The simple search in Google shows that IPV6 via Hyper-V NIC is a well-known Microsoft issue that was never solved. It works in the Host-> Hyper-V VM direction but not in the opposite direction. The answer was always "Disable IPV6 - it is never needed in the small networks!"Maybe, it is the option for some users but not for me.
I just tested it on the Laptop upgraded a few days ago to Win 11 using Ubuntu 20.04 distro and it definitely works with IPV4 and doesn't work with IPV6. The Network configuration is the same and the network capabilities are the same too: IPV6 router + IPV6 enabled by ISP for all customers infrastructure. Windows and router both use IPV6 capable DNS. Hey Microsoft! How long is needed to solve the Hyper-V issue reported years ago?
Simply connect to a VPN service like windscribe. Then do sudo apt-get update && sudo apt-get upgrade
(Especially those having issues after connection to different ISP or network provider)
Check IP online activity as well (maybe blacklisted or so) or contact your ISP to have the static IP changed
Good luck 🤞
Ok. This is annoying. I've futzed about with this on-and-off the last few days and still can't get anything to work. It worked perfectly fine on my old system, but after upgrading MB & CPU and fresh install of W11, I get no connection. I believe I have tried everything mentioned here and a few other places with no change. No VPN. This is clean install of W11
That's it. Clean. It works on my old board. The new board is an ASUS Strix Z690-A with an i7-12700KF. The old board is an ASUS Strix Z390-E with an i9-9900K. I put the old board in a rackmount case for an NVR did the same clean install above and everything works perfectly. Why? I did a second reinstall on the new system to verify my steps, but that didn't change anything. The new system will not connect. Side-by-side one works and the other don't, using virtually the same install procedure. What is causing the failure? Hardware? I haven't gotten around to trying Docker yet, is that going to be broken? Like others, downgrading to WSL v1 restores the connection, but I need WSL2.
This same issue affects Windows Sandbox. No internet connectivity. There is no vEthernet adapter. Tried creating one, but it won't connect: unidentified network. I've got two machines side-by-side with fresh installs of windows, updated, no other software. One works and one does not. Only difference is hardware. Maybe something about the ethernet controller or driver that Hyper-V doesn't like? I can get a working vEthernet by connecting to my wifi adapter, but still no connect in wsl2 or sandbox.
I got it working by not using ethernet adapter and using wifi adapter. It was mentioned in one of these billion Issues logged on the subject, but I couldn't get it working the first time I tried. I uninstalled all the virtualization features & wsl. I then installed only Hyper-V. Created my wifi v switch and made sure it was working. (Here, I also tried creating an ethernet v switch, but it would not connect: Unidentified network. I wish I had a different ethernet card to plug in and test. I think the problem is tied to the ethernet card in use or it's driver.) Then I installed Sandbox & WSL + Ubuntu. Now it is all working. Not correctly. It's a stupid workaround that I don't won't to use. I don't want to use wifi for this, and prefer to have my wifi disabled on the computer. The ethernet adapter on the other computer sitting next to me works just fine, out of the box. Why not this one?
I updated the /ect/wsl.conf
with
[network]
generateResolvConf = false
then closed the wsl window and ran wsl --shutdown
in powershell. Now the /etc/resolv.conf
is not being created on opening wsl. But I cant update the namespace 8.8.8.8
because the file does not exist :(
finally got it working :) I did the following to get it running. Open wsl and run the following commands:
sudo rm /etc/resolv.conf
sudo bash -c 'echo "nameservers 8.8.8.8" > /etc/resolv.conf'
sudo bash -c 'echo "[network]" > /etc/wsl.conf'
sudo bash -c 'echo "generateResolvConf=false" >> /etc/wsl.conf'
sudo chattr +i /etc/resolv.conf
wsl --shutdown
ping www.google.com
or sudo cat /etc/resolv.conf
. To check network and values of .confMy probably related report: https://github.com/microsoft/WSL/issues/8299
My current workaround: open a new WSLv1 tab and ping google.com in it, then the old WSLv1 bash processes start to work somehow, but maybe it's a coincidence
I have the same problem. Tried all steps above. I found out that if I switched to Wifi that my problem is resolved.. I still don't know why the ubuntu doesnt have internet on cable internet.. it's only the cable internet that has the problem.
I have the same problem but I fixed it by changing the Program Files\Windows Apps
folder ownership.
hello i have some problem my network manager not enable and my network manager not detect any wifi i tried every method to make network manager detect my windows wifi but is fail im using kali linux version 2022.2 and wsl 2 version 5.10.102.1-microsoft-standard-WSL2 please help me i want using kali linux for test spring4shell but docker need connection to wifi maybe you want look the screenshot i have enable systemctl but the problem come after systemctl enable please help me
Some other network driver is blocking WSL network. Uninstalling my VPN app solved the problem
I had the same exact problem as the OP @sbhatti534602210, and even tried all of the things they tried. What finally worked for me was suggested in this thread: https://superuser.com/a/1733426/1725434 . They suggest decompressing the files in %TEMP%
. I did that, and WSL2 networking works again! The only modification I made was to run cmd.exe as Admin.
My system was running low on hard drive space so I think Windows 10 started to compress files automatically to save space. You can stop Windows from doing this for a folder by following this: https://answers.microsoft.com/en-us/windows/forum/all/files-in-windows-10-automatically-compressing/491e517b-e5e9-44e7-8012-0f49f7696d6b
Or you can disable the auto-compression system-wide by running fsutil behavior set disablecompression 1
in PowerShell, although I am not sure if this is a recommended approach.
Hope this helps others.
For those that using Comodo antivirus/firewall, you definitely need to disable firewall (like suggested by many) in order to make network working in WSL Ubuntu.
I was facing this issue only under corporate firewall (Zscaler). Otherwise, WLS Ubuntu was able to connect to the network.
As suggested in this thread, some interaction of Hyper-V or Hyper-V plus docker desktop was the root cause for me. The steps I took:
System reboots at this level. When I try to start the ubuntu app on my laptop, it fails with error 0x80370102. In this thread, someone suggests to enable Hyper-V to avoid this error. But, this solution worked for me:
wsl --set-default-version 1
That's it. Once installation is over, there is no networking issue even when it's behind corporate firewall.
However, I will suggest to try the following simple steps first:
Try to use another wi-fi router. I've also done all the steps you've done and they haven't fixed the problem. After using another router (a pocket wifi actually) wsl connects now to the internet. So, I concluded that the problem was on my router, not on wsl or my computer...
happened to me today, is there no solution?
If you are having name resolution issues, please look at troubleshooting documentation we just added here: https://github.com/MicrosoftDocs/WSL/blob/main/WSL/troubleshooting.md#troubleshooting-dns-in-wsl.
It walks through some configurations which can break name resolution from the WSL container - as well as a work around for an HNS issue which can also break connectivity.
There are compatibility issues with some VPNs which want to see all packets from the top of the stack.
Some compat issues with VPNs can be addressed by updating the interface metrics so the vNIC for WSL is more preferred than the VPN interface. We document this https://learn.microsoft.com/en-us/windows/wsl/troubleshooting, see the sections "WSL has no network connectivity once connected to a VPN" and "Cisco Anyconnect VPN issues with WSL in NAT mode".
Microsoft Windows [Version 10.0.19043.1081] Ubuntu 20.04.2 LTS
I worked through the instructions for installing wsl for windows 10, from: https://docs.microsoft.com/en-us/windows/wsl/install-win10
However, I cannot connect to the internet from Ubuntu. I switched off the firewall as suggested here: https://docs.microsoft.com/en-us/windows/wsl/faq#why-do-i-not-have-internet-access-from-wsl-
But still could not connect.
There are a few things I have tried already but they did not resolve the problem (see below). As in the FAQ page: https://docs.microsoft.com/en-us/windows/wsl/faq#where-can-i-provide-feedback- I raised this through the issues tracker but did not get any response. Can someone help with this, please? I don't know why my previous request was closed without any response.
Thanks!
From Ubuntu terminal I tried to install:
curl https://get.volta.sh | bash (6) Could not resolve host: get.volta.sh
so I tried: ping 8.8.8.8 ping: connect: Network is unreachable
Some of the troubleshooting steps I have tried (which did not work)
Disabled the firewall.
Re-installed ubuntu.
BT (my internet provider), port forwarding: https://www.bt.com/help/broadband/learn-about-broadband/how-do-i-set-up-port-forwarding-on-my-bt-hub-
Checked Network Connection settings Ethernet Properties vEthernet Properties (WSL) Hyper-V Virtual Ethernet Adapter Internet Protocol Version 4 (TCP/IPv4) -checked Internet Protocol Version 6 (TCP/IPv6) -checked Hyper-V Extensible Virtual Switch -unchecked
Checked Device Manager (View Hidden) Network adapters > Hyper-V Virtual Ethernet Adapter Properties Device status - This device is working properly.
Turn Windows features on and off Uncheck Windows Subsystem for Linux Windows needs to reboot your PC to finish the requested changes Recheck Windows Subsystem for Linux Windows needs to reboot
Change the nameserver sudo nano /etc/resolv.conf '# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/resolv.conf '# [network] '# generateResolvConf = false nameserver xxx.xx.xx Change the name server to 8.8.8.8 and save the file. You should now be able to connect to the internet. -even restarted ubuntu, same error after restarting and the nameserver seems to be reset to default
https://github.com/microsoft/WSL/issues/5336#issuecomment-653881695 Open Powershell or Cmd as Administrator and run each of these commands: wsl --shutdown netsh winsock reset netsh int ip reset all netsh winhttp reset proxy ipconfig /flushdns Hit the Windows Key, type Network Reset, hit enter. You should see this window. Click "Reset now". Restart Windows