I have a python http.server running on the windows host:
C:\> python3 -m http.server 8000
The host has two ip addresses:
C:\> ipconfig
Ethernet adapter vEthernet (WSL):
IPv4 Address. . . . . . . . . . . : 172.28.224.1
Subnet Mask . . . . . . . . . . . : 255.255.240.0
Wireless LAN adapter WLAN:
IPv4 Address. . . . . . . . . . . : 123.123.123.123
The http server can be accessed from the host itself through both ip, together with localhost:
C:\> curl 123.123.123.123:8000
StatusCode : 200
StatusDescription : OK
Content : <!DOCTYPE HTML>
<html lang="en">
...
C:> curl 172.28.224.1:8000
StatusCode : 200
StatusDescription : OK
Content : <!DOCTYPE HTML>
<html lang="en">
...
C:> curl 127.0.0.1:8000
StatusCode : 200
StatusDescription : OK
Content : <!DOCTYPE HTML>
<html lang="en">
...
But I can't access the http server from inside WSL2, even though the host can be ping-ed:
~$ curl 172.28.224.1:8000
(hanging)
~$ ping 172.28.224.1
PING 172.28.224.1 (172.28.224.1) 56(84) bytes of data.
64 bytes from 172.28.224.1: icmp_seq=1 ttl=128 time=0.967 ms
64 bytes from 172.28.224.1: icmp_seq=2 ttl=128 time=1.77 ms
...
I have already set up some firewall rules:
C:\> New-NetFirewallRule -DisplayName WSL -InterfaceAlias "vEthernet (WSL)" -Direction Inbound -Action Allow -Protocol TCP
C:\> New-NetFirewallRule -DisplayName WSL -InterfaceAlias "vEthernet (WSL)" -Direction Outbound -Action Allow -Protocol TCP
C:\> New-NetFirewallRule -DisplayName wsl -Direction Inbound -LocalPort 8000 -Action Allow -Protocol TCP
C:\> New-NetFirewallRule -DisplayName wsl -Direction Outbound -LocalPort 8000 -Action Allow -Protocol TCP
Forwarding from WSL2 to 127.0.0.1 on host doesn't work either:
C:\> netsh int por add v4tov4 8000 127.0.0.1 8000 172.28.224.1
~$ curl 172.28.224.1:8000
(hanging)
Does anyone know if I'm missing anything for accessing the host from WSL2? If I'm not, how should I debug this?