WSL: Curl failed by ping can succeeds on WSL2

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

Steps to reproduce

  1. Under my company’s network, curl always failed but ping can succeeds always on WSL 2.
    cordius@L-81390457-0939:~$ ping www.baidu.com
    PING www.a.shifen.com (180.101.49.11) 56(84) bytes of data.
    64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=1 ttl=45 time=18.3 ms
    64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=2 ttl=45 time=18.7 ms
    64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=3 ttl=45 time=17.9 ms
    ^C
    --- www.a.shifen.com ping statistics ---
    3 packets transmitted, 3 received, 0% packet loss, time 2004ms
    rtt min/avg/max/mdev = 17.952/18.359/18.753/0.345 ms
    
    cordius@L-81390457-0939:~$ curl -vvv www.baidu.com
    * Rebuilt URL to: www.baidu.com/
    *   Trying 180.101.49.12...
    * TCP_NODELAY set
    * connect to 180.101.49.12 port 80 failed: Connection timed out
    *   Trying 180.101.49.11...
    * TCP_NODELAY set
    ^C
    
  2. Under my company’s network, curl and ping both succeeds always on WSL 1.
  3. Under my family network, curl and ping both succeeds on both WSL1 and WSL 2.

Expected behavior

Curl should succeed too under my company’s network on WSL 2.

Actual behavior

Curl failed under my company’s network on WSL 2.

Notes

I have tried a lot of workarounds mentiond by other issues such as #4698, but these methods didn’t work for me.

BTW, I tried to captures packets by Wireshark and it seems that the TCP SYN can’t get a ACK.

image

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 26 (1 by maintainers)

Most upvoted comments

Well, I found what the problem is in my case. My computer have been installed Symantec Endpoint Protection by security team of my company. And the SEP blocked all TCP traffic sent from WSL2.

Well, I found what the problem is in my case. My computer have been installed Symantec Endpoint Protection by security team of my company. And the SEP blocked all TCP traffic sent from WSL2.

Did you find a way around Symantec Endpoint Protection?

I am having the same issue, and I just can’t use WSL2 at the moment.

 Fix network issues
# Delete auto-generated files
[root@PC-NAME user]# rm /etc/resolv.conf || true
[root@PC-NAME user]# rm /etc/wsl.conf || true

# Enable changing /etc/resolv.conf
# Enable extended attributes on Windows drives
[root@PC-NAME user]# cat <<EOF > /etc/wsl.conf
[network]
generateResolvConf = false

[automount]
enabled = true
options = "metadata"
mountFsTab = false
EOF

# Use google nameservers for DNS resolution
[root@PC-NAME user]# cat <<EOF > /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF

Try changing nameserver in /etc/resolv.conf after that exit the linux.

cmd as admin:

wsl --shutdown
netsh winsock reset
netsh int ip reset all
netsh winhttp reset proxy
ipconfig /flushdns

Windows Search > Network Reset

It save me couple times, when installing Gentoo WSL & Funtoo WSL. ping wget failed, but I can update the repo.

Sadly I have to say that all of the above mentions workaround does not work for me. I use Windows 10 Version 20H2.

Previously my WSL2 , Ubuntu-20.04 was working perfectly. I notice the problem only after recent windows update.

My WSL2 statistic:

If I revert to WSL1, and the issue solved.

@tbehling you are the one! I’ve experienced exactly the same behaviour and the worst thing is that I was trying to troubleshoot a dockerized env on WSL2. Took me days and finally landed on your post. Setting Mtu to 1400 on the WSL2 eth0 nic fixes the problem…now I have to also set mtu on docker virtual nics.

To make “persistent” changes to WSL2, I use the wsl command from Windows at boot time using a scheduled task. In you case I would do wsl -u root ip link set eth0 mtu 1400 I succesfully use this method to start cron and rsyslog services that are not persistent on WSL2.

win10 block the WSL interface traffic. you should do this in the win10 powershell to allow the traffic

sudo Set-NetFirewallProfile -DisabledInterfaceAliases "vEthernet (WSL)"

@rescenic thank you, it worked!