Saturday, April 27, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 16157  / 3 Years ago, thu, may 27, 2021, 3:08:54

i am running Ubuntu-20.04 in WSL 2 on Win 10.

I have got no internet connection in WSL,

ping 8.8.8.8 shows From <a ip> icmp_seq=1 Destination Host Unreachable


networkctl shows


WARNING: systemd-networkd is not running, output will be incomplete.

IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback n/a unmanaged
2 bond0 bond n/a unmanaged
3 dummy0 ether n/a unmanaged
4 tunl0 tunnel n/a unmanaged
5 sit0 sit n/a unmanaged
6 eth0 ether n/a unmanaged

6 links listed.

when i run networkctl reconfigure eth0
it shows


WARNING: systemd-networkd is not running, output will be incomplete.

Failed to connect system bus: No such file or directory

Any idea to restore the network connection? Thanks in advance


More From » networking

 Answers
6

Thanks for reposting this from Stack Overflow. As I implied on my comment on that original question, I think there are two issues/questions going on here:



  • The main one is that you don't have Internet access, of course.

  • Secondary is that you are trying to use the networkctl command under WSL, which won't work.


Let's start with the second one. As I mentioned in my comment, networkctl won't work for the reason that's mentioned in my answer here. That is:



systemd-networkd is not running, output will be incomplete.



That tells you that this (the networkctl issue) is Systemd-related. As noted in that answer, Systemd isn't supported on WSL without additional effort (that I tend to not recommend).


So as with systemctl, you need other alternatives. For instance, the ip command:



  • ip link (or ip link show) will show you the status of the network devices.

  • ip addr/ip address will show you the IP addresses in use on those devices.


That said, with networking on WSL2, there's often not much that you can do internally (in Ubuntu) to fix it (or even diagnose the issue). I'll be honest, resolving networking issues under WSL2 can be difficult, but we'll try ...


Just as a preface, WSL2 networking is provided by either:



  • The "Virtual Machine Platform" feature (typically)

  • Or, alternatively, the Hyper-V manager (on Windows Pro or higher)


Both are essentially the same core Windows code, but the VMP is a scaled down version that runs on Windows Home so that you can use WSL2 there (since Hyper-V isn't available on Home).


WSL2 sets up a virtual Hyper-V network switch that sits "between" the WSL2 network and the Windows "real" network. The WSL2 instance normally is NAT'd behind that virtual switch.


So when you face issues with networking in WSL just not working, it's typically because of some failure of the virtual switch to communicate with the host.


Some of the more common causes:



  • If Windows is connected to a VPN, the VPN software will often block other local connections. Since WSL2 is a separate local network location, it cannot operate when connected to the VPN.


    If this is the case for you, the answer may be dependent on your actual VPN. One workaround or solution for Cisco AnyConnect, at least, appears to be to increase the interface metric for the VPN adapter so that (I believe) local connections take priority.



  • The WSL2 network switch is also susceptible to problems in the swap file, for some reason. Sometimes see my Stack Overflow answer on that topic. Disabling swap (via %userprofile%.wslconfig) has solved WSL2 networking problems for a number of users.



  • Occasionally, there have been Microsoft patches that corporate IT has pushed to systems that have caused the WSL2 network to break. Usually, that's indicated by it working previously but then no longer working spontaneously.



  • And there are a number of other troubleshooting steps you can try. Some great ones are listed at the bottom of the same SO question (in the things already tried), but there are some additional answers there to try as well.




[#440] Friday, May 28, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ellter

Total Points: 311
Total Questions: 111
Total Answers: 117

Location: Lithuania
Member since Thu, Jul 14, 2022
2 Years ago
ellter questions
Sat, Jul 9, 22, 07:55, 2 Years ago
Tue, Jun 1, 21, 05:28, 3 Years ago
Wed, Oct 6, 21, 00:08, 3 Years ago
;