Skip to content

No network connection in any distribution under WSL 2 #5336

Closed

Description

Environment

Windows build number: 10.0.19041.0
Your Distribution version: Ubuntu-18.04
Whether the issue is on WSL 2 and/or WSL 1: WSL 2 only (Linux version 4.19.104-microsoft-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Wed Feb 19 06:37:35 UTC 2020)

Steps to reproduce

I have installed WSL 2 on a new Windows 10 Education machine managed by my employer (university) following the online instructions. Whenever I create a new distribution using WSL version 2 I have no network connection.

duncan@Macleod-XPS:/mnt/c/Users/spxdmm$ ping google.com
ping: google.com: Temporary failure in name resolution
duncan@Macleod-XPS:/mnt/c/Users/spxdmm$ ping 127.0.0.1
connect: Network is unreachable
duncan@Macleod-XPS:/mnt/c/Users/spxdmm$ ifconfig eth0
eth0: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 00:15:5d:a5:38:8b  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

duncan@Macleod-XPS:/mnt/c/Users/spxdmm$ cat /etc/resolv.conf
# 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 192.168.176.1

Gist of strace here: https://gist.github.com/duncanmmacleod/4a69a363bf990c3a0dead811b22ce6d5

If I use wsl --set-version to roll back the distribution to WSL 1 I get a network connection just fine.

Expected behavior

New distributions on WSL 2 have a working network connection out-of-the-box.

Actual behavior

See above

Thanks, sorry if this is a duplicate of an existing issue (I surely can't be the only one...)

Activity

  1. rescenic commented on Jun 4, 2020

    @rescenic

    Try network reset or allow in firewall.

  2. duncanmmacleod commented on Jun 4, 2020

    @duncanmmacleod
    Author

    Can you be any more specific about how to do either of those things? I'm new to Windows (just migrating back from macOS).

  3. onomatopellan commented on Jun 4, 2020

    @onomatopellan

    Try something like ping 216.58.192.164. Does it work?

  4. duncanmmacleod commented on Jun 4, 2020

    @duncanmmacleod
    Author
    $ ping 216.58.192.164
    connect: Network is unreachable
  5. onomatopellan commented on Jun 4, 2020

    @onomatopellan

    See #4731

  6. duncanmmacleod commented on Jun 4, 2020

    @duncanmmacleod
    Author

    Ok, looks like this is a duplicate of #4731, is that what you mean Jonathan (@onomatopellan)?

  7. onomatopellan commented on Jun 4, 2020

    @onomatopellan

    Hard to say. There are more threads with "Network is unreachable" where people tries to solving it in different ways like in #4275 (comment)

    It depends of your networking configuration, if you are using some VPN, proxy configuration... Try any of the solutions of those threads and if nothing work the best you can do is post a link to a networking trace so the team can take a look at it.

  8. duncanmmacleod commented on Jun 4, 2020

    @duncanmmacleod
    Author

    Thanks Jonathan (@onomatopellan), I don't have any special networking configuration, so will post a tracr using the feedback hub.

  9. wi-ry commented on Jun 9, 2020

    @wi-ry

    Try any of the solutions of those threads and if nothing work the best you can do is post a link to a networking trace so the team can take a look at it.

    I’ve shared my network trace: https://aka.ms/AA8mo2v

    WSL1 works fine, WSL2 does not. Downgrading from WSL2 to WSL1 restores connectivity.

  10. ericct commented on Jun 9, 2020

    @ericct

    Maybe related to #5286 ?

  11. duncanmmacleod commented on Jun 9, 2020

    @duncanmmacleod
    Author

    Try any of the solutions of those threads and if nothing work the best you can do is post a link to a networking trace so the team can take a look at it.

    https://aka.ms/AA8mo2v

    mrausnadian, 'my account doesn't have access to that feedback', can you please summarise the content of that link?

  12. yooceii commented on Jun 10, 2020

    @yooceii

    I disabled the Hyper-v feature. The network backs to normal.

  13. habamax commented on Jun 10, 2020

    @habamax

    I disabled the Hyper-v feature. The network backs to normal.

    How did you do it? If I disable it in windows features then wsl just doesn't run "The request is not supported".

  14. rescenic commented on Jun 10, 2020

    @rescenic

    @habamax commented on Jun 10, 2020, 7:38 PM GMT+7:

    I disabled the Hyper-v feature. The network backs to normal.

    How did you do it? If I disable it in windows features then wsl just doesn't run "The request is not supported".

    Convert the linux to WSL 1.

  15. habamax commented on Jun 10, 2020

    @habamax

    @habamax commented on Jun 10, 2020, 7:38 PM GMT+7:

    I disabled the Hyper-v feature. The network backs to normal.

    How did you do it? If I disable it in windows features then wsl just doesn't run "The request is not supported".

    Convert the linux to WSL 1.

    How does it solve the issue with wsl2?

    PS, wanted to use wsl2 but it is not ready.

  16. 199 remaining items

  17. jby commented on Nov 24, 2023

    @jby

    How did this turn into an issue about DNS?
    I have the same problem as Duncan Macleod (@duncanmmacleod) in the original post.
    Windows 10, WSL1, Ubuntu -> works fine
    Convert to WSL2 -> No network traffic leaving the Ubuntu install, I don't even get a ping response from the Windows host - the Windows host can ping the WSL2 Ubuntu install though.

  18. jby commented on Nov 24, 2023

    @jby

    The reported failures in DNS resolution is a result of the problem - not the cause...

  19. Elektronenvolt commented on Dec 3, 2023

    @Elektronenvolt

    The reported failures in DNS resolution is a result of the problem - not the cause...

    Can confirm this statement. In our case Windows Defender blocked incoming DNS for the WSL network adapter. In other cases here VPN clients caused DNS troubles, e.g.

  20. jansturm1 commented on Apr 4, 2024

    @jansturm1

    Only solution that worked for me (https://superuser.com/a/1671057/1662386):

    Add the following to your <windows_user_profile>/.wslconfig:

    [wsl2]
    networkingMode=mirrored
    Exit your WSL distribution
    
    

    Run wsl --shutdown from PowerShell then restart WSL

  21. Kieran-Sears commented on Apr 15, 2024

    @Kieran-Sears

    Duncan Macleod (@duncanmmacleod) Did you ever solve this? I'm experiencing the same exact issue on 19041.329. I hardly consider using WSL 1 a reasonable solution.

    I'm also finding that setting the name server and adding generateResolvConf = false to /etc/wsl.conf has no effect - it gets regenerated after every restart.

    I believe you need to include [network] above it, just having generateResolvConf = false doesn't cut it.

  22. zeroarst commented on May 21, 2024

    @zeroarst

    Only solution that worked for me (https://superuser.com/a/1671057/1662386):

    Add the following to your <windows_user_profile>/.wslconfig:

    [wsl2]
    networkingMode=mirrored
    Exit your WSL distribution
    

    Run wsl --shutdown from PowerShell then restart WSL

    I got

    wsl: Mirrored networking mode is not supported, falling back to NAT networking
    

    Any idea?

  23. keith-horton commented on May 21, 2024

    @keith-horton
    Member

    Mirrored Mode requires Windows 11 22H2 and higher. And the optional component "Virtual Machine Platform" is installed.

    Thanks!

  24. InternetPseudonym commented on May 21, 2024

    @InternetPseudonym

    Mirrored Mode requires Windows 11 22H2 and higher. And the optional component "Virtual Machine Platform" is installed.

    Thanks!

    oh, nice ... a version-locked feature and the the version it is locked to just so happens to be the most ad-ridden one of all time. I see the marketing department finally took full control. Well. It really "is" time to switch / virtualize / pirate winblows, then. Who would've thought.

  25. Elektronenvolt commented on May 21, 2024

    @Elektronenvolt

    Mirrored Mode requires Windows 11 22H2 and higher. And the optional component "Virtual Machine Platform" is installed.
    Thanks!

    oh, nice ... a version-locked feature and the the version it is locked to just so happens to be the most ad-ridden one of all time. I see the marketing department finally took full control. Well. It really "is" time to switch / virtualize / pirate winblows, then. Who would've thought.

    Well, I would call it 'dependency' 🧐But, what is 'version locked' in this case? Don't see it...

  26. hub977 commented on Jul 30, 2024

    @hub977

    我参考此链接得以在WSL2下恢复网络 https://learn.microsoft.com/zh-cn/windows/wsl/troubleshooting

    1.允许 DNS 数据包共享访问的 HNS 防火墙规则可能无效,引用以前的 WSL 接口标识符。 这是 HNS 中的一处缺陷,在最新的 Windows 11 版本已得到修复。 在早期版本中如果发生这种情况,虽然不容易发现,但有一个简单的解决方法:

    2.停止 WSL

    wsl.exe –shutdown

    3.删除旧的 HNS 防火墙规则。 大多数情况下,此 Powershell 命令应正常工作:

    Get-NetFirewallRule -Name "HNS*" | Get-NetFirewallPortFilter | where Protocol -eq UDP | where LocalPort -eq 53 | Remove-NetFirewallRule

    4.移除所有 HNS 终结点。 注意:如果使用 HNS 管理其他容器(例如 MDAG 或 Windows 沙盒),则还应停止这些容器。

    hnsdiag.exe delete all

    5.重新启动或重启 HNS 服务

    Restart-Service hns #如果重启hns报错,需要依赖项,可重启电脑解决

    6.重启 WSL 后,HNS 将创建新的防火墙规则,并正确面向 WSL 接口。

    C:\Users\Administrator>wsl -l -v
    NAME STATE VERSION

    • kali Stopped 2
      C:\Users\Administrator>wsl
      ┏━(Message from Kali developers)
      ┃
      ┃ This is a minimal installation of Kali Linux, you likely
      ┃ want to install supplementary tools. Learn how:
      ┃ ⇒ https://www.kali.org/docs/troubleshooting/common-minimum-setup/
      ┃
      ┗━(Run: “touch ~/.hushlogin” to hide this message)
      ┌──(root㉿BOT)-[/mnt/c/Users/Administrator]
      └─# ping 8.8.8.8
      PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
      64 bytes from 8.8.8.8: icmp_seq=1 ttl=48 time=59.3 ms
      64 bytes from 8.8.8.8: icmp_seq=2 ttl=48 time=64.6 ms
      64 bytes from 8.8.8.8: icmp_seq=3 ttl=48 time=58.2 ms
      64 bytes from 8.8.8.8: icmp_seq=4 ttl=48 time=101 ms
      64 bytes from 8.8.8.8: icmp_seq=5 ttl=48 time=61.6 ms
      ^C
      --- 8.8.8.8 ping statistics ---
      5 packets transmitted, 5 received, 0% packet loss, time 4007ms
      rtt min/avg/max/mdev = 58.243/69.056/101.487/16.363 ms

    如上ping 8.8.8.8可以通

  27. hub977 commented on Jul 30, 2024

    @hub977

    我参考此链接得以在WSL2下恢复网络 https://learn.microsoft.com/zh-cn/windows/wsl/troubleshooting

    1.允许 DNS 数据包共享访问的 HNS 防火墙规则可能无效,引用以前的 WSL 接口标识符。这是 HNS 中的一处缺陷,在最新的 Windows 11 版本已得到修复。在早期版本中如果发生这种情况,虽然不容易发现,但有一个简单的解决方法:

    2.停止 WSL

    wsl.exe –关闭

    3.删除旧的 HNS 防火墙规则。大多数情况下,此 Powershell 命令应正常工作:

    Get-NetFirewallRule -名称“HNS*” |Get-NetFirewallPortFilter |其中 Protocol -eq UDP |其中 LocalPort -eq 53 |删除 NetFirewallRule

    4.移除所有 HNS 终结点。注意:如果使用 HNS 管理其他容器(例如 MDAG 或 Windows 沙盒),则还应停止这些容器。

    hnsdiag.exe全部删除

    5.重新启动或重启 HNS 服务

    Restart-Service hns #如果重启hns报错,需要依赖项,可重启电脑解决

    6.重启 WSL 后,HNS 将创建新的防火墙规则,并正确面向 WSL 接口。

    C:\Users\Administrator>wsl -l -v 名称状态版本

    • kali 已停止 2 C:\Users\Administrator>wsl ┏━(Kali 开发者的消息) ┃ ┃ 这是 Kali Linux 的最小安装,您可能 ┃ 想要安装补充工具。了解如何操作: ┃ ⇒ https://www.kali.org/docs/troubleshooting/common-minimum-setup/ ┃ ┗━(运行: “touch ~/.hushlogin” 隐藏此消息) ┌──(root㉿BOT)-[/mnt/c/Users/Administrator] └─# ping 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 56(84) 字节的数据。 8.8.8.8 的 64 个字节: icmp_seq=1 TTL=48 时间=59.3 毫秒 8.8.8 的 64 个字节: icmp_seq=2 TTL=48 时间=64.6 毫秒 8.8.8 的 64 个字节: icmp_seq=3 TTL=48 时间=58.2 毫秒 8.8.8.8 的 64 个字节: icmp_seq=4 TTL=48 时间=101 毫秒 8.8.8.8 的 64 个字节: icmp_seq=5 TTL=48 时间=61.6 毫秒 ^C --- 8.8.8.8 ping 统计--- 传输的 5 个数据包, 接收 5 个,数据包丢失率为 0%,时间 4007ms RTT 最小值/平均值/最大值/MDev = 58.243/69.056/101.487/16.363 毫秒

    如上ping 8.8.8.8可以通

    本人系统环境为windows 10.0.19044
    同时需要在 /etc/resolv.conf中写入servername 8.8.8.8
    /etc/wsl.conf中写入
    [network]
    generateResolvConf = false

    希望能帮助到你!!!

  28. friedinando commented on Aug 11, 2024

    @friedinando

    In my case, this config fix the problem:

    [wsl2]
    networkingMode=mirrored
    Exit your WSL distribution

  29. tannath commented on Oct 10, 2024

    @tannath

    Before use name like eth0 of device with internet access - check device name by:

      Get-NetAdapter
    

    A working solution on mode bridged

    On windows brand new virtual device (enable features of hyper-v in cli):

      Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V
      Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Management-PowerShell
    

    make by:

      New-VMSwitch -Name "External Device" -NetAdapterName eth0
    

    And finally firewall, yep firewall ( your $clsid will be different - Name) :

      Get-NetFirewallHyperVVMSetting
    
      Name "{b26585cf-342b-471d-93a6-763ac5dba536}"
      Enabled               : True
      DefaultInboundAction  : Allow
      DefaultOutboundAction : Allow
      LoopbackEnabled       : True
      AllowHostPolicyMerge  : True
    
      $clsid = "{b26585cf-342b-471d-93a6-763ac5dba536}"
    
      Set-NetFirewallHyperVVMSetting -Name $clsid -Enabled True -DefaultInboundAction Allow
       -DefaultOutboundAction Allow -LoopbackEnabled True -AllowHostPolicyMerge True
    

    On windows in file at c:/Users/<name_of_user>/.wslconfig

      [wsl2]
      networkingMode=bridged
      vmSwitch="External Device"
      dhcp=true
      ipv6=true
    
      [experimental]
      dnsTunneling=true
      firewall=true
    
  30. craigloewen-msft commented on May 27, 2025

    @craigloewen-msft
    Member

    I'm closing out old issues. This has been around for a while. If you're still seeing this with the latest version of WSL please open a new issue. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions