4

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

3 Answers3

4

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.

NotTheDr01ds
  • 17,888
1

The only thing that worked for me: in Windows open Networks & Internet setting go to network connection: deactivate the "vEthernet(WSL): Hyper-V Virtual Ethernet Adapter" and reactivate it.

chekkal
  • 111
0

Adding a slightly contradictory point to NotTheDr01ds's comment on VPNs:

I have been facing the same connectivity issues recently- it used to work fine earlier though; 2-3 months ago is when I last checked things in WSL.

After going through many posts and comments about this issue, I just decided to try using WSL WITH VPN ON and it started working. Doesn't work without VPN, works with VPN.

So if you guys have any VPN's configured or VPN software installed, try with the VPN on.