microsoft / WSL

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

No network access from WSL/Ubuntu #7141

Open sbhatti534602210 opened 3 years ago

sbhatti534602210 commented 3 years ago

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)

  1. Disabled the firewall.

  2. Re-installed ubuntu.

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

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

  5. Checked Device Manager (View Hidden) Network adapters > Hyper-V Virtual Ethernet Adapter Properties Device status - This device is working properly.

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

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

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

Puvipavan commented 8 months ago

The solution worked for me is(I do not use Hyper-V, Maybe you could do other way around if you use Hyper-V):

Turning on Hyper-V does some magic :P I had to do the same after installing updates too.

Note: I wasn't experiencing name resolution issue

vadimkantorov commented 8 months ago

@keith-horton This has just occurred for me after months of this being not happening:

  1. After recovery from hibernate on a different Wi-Fi network, in cmd.exe I can ping google.com
  2. in existing WSLv1 session and on new WSLv1 session, DNS lookups stopped working: Temporary failure in name resolution, ping of goolge by IP still works
  3. nslookup crashes in a bad way
  4. gdb with bt doesn't work :(
image image image image
Starting program: /usr/bin/nslookup
warning: opening /proc/PID/mem file for lwp 2496.2496 failed: No such file or directory (2)
Failed to read a valid object file image from memory.
[New LWP 2499]
> google.com
;; UDP setup with fec0:0:0:ffff::1#53(fec0:0:0:ffff::1) for google.com failed: invalid file.
;; UDP setup with fec0:0:0:ffff::1#53(fec0:0:0:ffff::1) for google.com failed: invalid file.
;; UDP setup with fec0:0:0:ffff::1#53(fec0:0:0:ffff::1) for google.com failed: invalid file.
;; UDP setup with fec0:0:0:ffff::2#53(fec0:0:0:ffff::2) for google.com failed: invalid file.
;; UDP setup with fec0:0:0:ffff::3#53(fec0:0:0:ffff::3) for google.com failed: invalid file.
task.c:805: INSIST((task->events).head != (event)) failed, back trace
/lib/x86_64-linux-gnu/libisc-9.18.12-0ubuntu0.22.04.3-Ubuntu.so(+0x32b13)[0x7fffff212b13]
/lib/x86_64-linux-gnu/libisc-9.18.12-0ubuntu0.22.04.3-Ubuntu.so(isc_assertion_failed+0x10)[0x7fffff212780]
/lib/x86_64-linux-gnu/libisc-9.18.12-0ubuntu0.22.04.3-Ubuntu.so(isc_task_run+0x422)[0x7fffff239fd2]
/lib/x86_64-linux-gnu/libisc-9.18.12-0ubuntu0.22.04.3-Ubuntu.so(+0x2653e)[0x7fffff20653e]
/lib/x86_64-linux-gnu/libisc-9.18.12-0ubuntu0.22.04.3-Ubuntu.so(+0x26cb7)[0x7fffff206cb7]
/lib/x86_64-linux-gnu/libisc-9.18.12-0ubuntu0.22.04.3-Ubuntu.so(+0x26ed6)[0x7fffff206ed6]
/lib/x86_64-linux-gnu/libuv.so.1(+0x91ed)[0x7ffffec891ed]
/lib/x86_64-linux-gnu/libuv.so.1(+0x2511e)[0x7ffffeca511e]
/lib/x86_64-linux-gnu/libuv.so.1(uv_run+0x678)[0x7ffffec8ec88]
/lib/x86_64-linux-gnu/libisc-9.18.12-0ubuntu0.22.04.3-Ubuntu.so(+0x2734a)[0x7fffff20734a]
/lib/x86_64-linux-gnu/libisc-9.18.12-0ubuntu0.22.04.3-Ubuntu.so(isc__trampoline_run+0x1a)[0x7fffff23dd4a]
/lib/x86_64-linux-gnu/libc.so.6(+0x94ac3)[0x7ffffed54ac3]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x44)[0x7ffffede5bf4]

Thread 2 "isc-net-0000" received signal SIGABRT, Aborted.
[Switching to LWP 2499]
0x00007ffffed569fc in ?? ()
(gdb) thread apply all bt

Thread 2 (LWP 2499 "isc-net-0000"):
#0  0x00007ffffed569fc in ?? ()
Backtrace stopped: Cannot access memory at address 0x7ffffbd4c3e0

Thread 1 (LWP 2496 "nslookup"):
#0  0x00007ffffed0321a in ?? ()
Backtrace stopped: Cannot access memory at address 0x7ffffffedf80
(gdb) bt
#0  0x00007ffffed569fc in ?? ()
Backtrace stopped: Cannot access memory at address 0x7ffffbd4c3e0

this is on

Description:    Ubuntu 22.04.3 LTS
Release:        22.04
Codename:       jammy
Puvipavan commented 8 months ago

@vadimkantorov It's DNS issue. You need to explore about "fixing DNS issue on WSL".

vadimkantorov commented 8 months ago

I checked https://github.com/MicrosoftDocs/WSL/blob/main/WSL/troubleshooting.md#troubleshooting-dns-in-wsl. I don't think my situation is described there, but I don't have time/skills for a deeper investigation.

I just thought that the nslookup crash and stack trace is interesting, I don't think I saw it in this discussion, so I hope it's helpful for further people reporting. Might be it's a different flavor of DNS problems issues

Puvipavan commented 8 months ago

@vadimkantorov try this: https://github.com/microsoft/WSL/issues/7141#issuecomment-1092965552

vadimkantorov commented 8 months ago

yeah, maybe the problems is that resolv.conf sometimes doesn't get regenerated after hibernate recovery on a new Wi-Fi network

keith-horton commented 7 months ago

I highly recommend doing this step #4 if you are using NAT and having DNS issues:

  1. The HNS Firewall rule to allow the DNS packets to shared access can become invalid, referencing a previous WSL interface identifier. This is a flaw within HNS which has been fixed with the latest Windows 11 release. On earlier releases, if this occurs, it’s not easily discoverable, but it has a simple work around:

Stop WSL wsl.exe –shutdown Delete the old HNS Firewall rule. This Powershell command should work in most cases: 1.Get-NetFirewallRule -Name "HNS*" | Get-NetFirewallPortFilter | where Protocol -eq UDP | where LocalPort -eq 53 | Remove-NetFirewallRule Remove all HNS endpoints Note: if HNS is used to manage other containers, such as MDAG or Windows Sandbox, those should also be stopped. hnsdiag.exe delete all Reboot or restart the HNS service When WSL is restarted, HNS will create new Firewall rules, correctly targeting the WSL interface.

EDIT: by #4, I mean #4 from the above link for troubleshooting DNS in WSL.

murdoc99gtp commented 2 months ago

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 know this thread is a few years old. Was there a fix determined for this issue? I am having the exact same issue with the same board series, ROG Strix Z690-E Gaming motherboard on Windows 11. The z690 onboard LAN will not connect to my cisco catalyst ws-c3550. But I have four other intel chipset motherboards (z670 prime, z170, h81 & z68) that have no problem connecting.

krnaveen14 commented 6 days ago

I faced same issue in my Work Desktop (connected to corporate network). Setting the DNS nameserver to 8.8.8.8 doesn't make sense as it would make internal sites unresolvable.

I came up the following solution as a workaround - Fix for WSL2 No Internet

1) Find DNS Server used by Windows

# 10.9.8.169 is the DNS Server in my system (Corporate Device / Network)
ipconfig /all | findstr /R "DNS\ Servers"

2) Set DNS Nameserver in WSL

sudo bash -c "echo 'nameserver <dns_server_from_prev_cmd>' > /etc/resolv.conf"

# For personal devices without DNS Server configured, use 8.8.8.8 or any other preferred resolver