2

I am running a console app in Windows 10 which has a self-hosted HTTPS server listening on port 44340. It's an ASP.NET Core website (Kestrel) and its perfectly browsable on the Windows side.

I cannot reach this port from within a Windows Subsystem for Linux 2 (WSL2) console running Ubuntu 18.04, testing with curl.

I've tried adding a Windows Firewall rule for that port but it doesn't seem to work.

I've tried via localhost, as well as the two IPs I can see for my machine. One is the real NIC using DHCP and the other is a vEthernet adapter for WSL with a 172.31 address.

Luke Puplett
  • 939
  • 2
  • 16
  • 24

2 Answers2

0

Here's what I did.

  • Disabled the Windows Firewall (then once proven working, re-enabled and added a rule).
  • Add a hosts file entry on the Windows side for host xyz pointing at my physical NIC IP.
  • Created a self-signed certificate for xyz.
  • Configured Kestrel to listen on the physical NIC IP and load the certificate for xyz
  • Checked the Windows side worked with Chrome.
  • Launched WSL and pinged xyz.
  • Ran curl https://xyz:44340 and observed the failure to validate my self-signed cert.

That confirms TCP is working, so I'm off to bed. Essentially the blockers were:

  • Firewall.
  • Kestrel not listening on the right IP.
Luke Puplett
  • 939
  • 2
  • 16
  • 24
0

See guidance here

https://docs.microsoft.com/en-us/windows/wsl/networking#accessing-windows-networking-apps-from-linux-host-ip

If you want to access a networking app running on Windows (for example an app running on a NodeJS or SQL server) from your Linux distribution (ie Ubuntu), then you need to use the IP address of your host machine. While this is not a common scenario, you can follow these steps to make it work.

Obtain the IP address of your host machine by running this command from your Linux distribution: cat /etc/resolv.conf Copy the IP address following the term: nameserver. Connect to any Windows server using the copied IP address. The picture below shows an example of this by connecting to a Node.js server running in Windows via curl.

You will also need to allow inbound connections to that port in the host. (Through a firewall rule).

Dasith Wijes
  • 121
  • 5