Windows WSL 2 can't ping host machine

2

I just upgraded to Windows WSL 2 today. The problem is I can't ping the host machine.

I got the IP for the host machine from /etc/resolv.conf.

From WSL 2 Ubuntu console:

  • I can ping 8.8.8.8.
  • I can not ping 172.17.12.65 (host machine).
  • I can not ping www.google.com

Please help, thanks!

Jie

Posted 2019-06-17T18:44:36.800

Reputation: 21

Seems strange you can ping your DNS server hosted by Google but are unable to ping a different google domain. What IP address does Windows believe your host machine is assigned to? (172.17.xxx.xxx) is not a typical intranet address. – Ramhound – 2019-06-17T18:51:19.080

Try to run WSL as admin. Also check in /etc/resolv.conf the nameserver line. – harrymc – 2019-06-17T19:06:51.653

Yes this is an issue. MS will make this as bridged mode in future. – Biswapriyo – 2019-06-18T03:10:19.150

@Biswapriyo, do you know the issue tracker? I have gone back to WSL 1, since I can't use VcXsrv because of this issue. Thanks! – Jie – 2019-06-18T16:38:49.483

Answers

1

Only answering as I bumped into the same issue.

First, unlikey one comment implied, 172.16.. - 172.31.. is reserved private IP Address, so I'm pretty sure 172.17.12.65 is valid for your host.

I found ipconfig in cmd.exe reveals that nameserver address in /etc/resolv.conf is actually the address of vEthernet(WSL).

Maybe the issue has something to do with hyper-v ethernet adaptor?

andoryu-

Posted 2019-06-17T18:44:36.800

Reputation: 11

1

Some indication from this github thread suggests that it may be simply the firewall on your Windows host blocking the traffic...

https://github.com/microsoft/WSL/issues/4192#issuecomment-503804455

Quoting xtremeperf:

"Actually... you're probably being blocked by the Windows firewall, as WSL2 is considered to be on a "Public Network". You'll need to open these ports manually on the Windows firewall because they are not yet automatically configured upon installation in this early beta release."

Like harrymc and andoryu- said, check the content of "/etc/resolv.conf" to check the WSL2 IP. AFAIK it should be the one to unblock.

Unfortunately the virtual switch adapter connection profile for WSL2 is "Public" by default, and cannot be set to "Private" permanently unless you can assign a VLAN ID to the adapter, but I don't currently know of way to do that with Microsoft's Virtual Machine Platform feature, which is what I am using. Hopefully Microsoft will allow this to be easily changed in a future release. I haven't yet researched if it is possible to run WSL2 using Microsoft's Hypervisor Platform feature only. If someone knows, that may be helpful.

Although it may not be desirable, you can simply allow inbound ICMP echo traffic on the host firewall for "Public" profiles. An example using Windows Defender:

  1. Launch Windows Defender Firewall via Control Panel.
  2. Select "Advanced Settings" (on the left)
  3. Right-click "Inbound Rules" and choose "New Rule..."
  4. Choose "Custom" and click "Next"
  5. Choose "All Programs" and click "Next"
  6. Select the "ICMPv4" protocol type, then click "Customize..."
  7. Choose "Specific ICMP types" and check "Echo Request" and click "OK", then "Next"
  8. Choose "Any IP Address" or add specific addresses as you require for Local and Remote (in your case ), and click "Next"
  9. Choose "Allow the connection" and click "Next"
  10. Choose Public, Domain and Private and click "Next"
  11. Give the rule a meaningful name and click "Finish"

Johan van Tonder

Posted 2019-06-17T18:44:36.800

Reputation: 11