When I run
PS C:\WINDOWS\system32> wsl hostname -I
172.27.96.44
PS C:\WINDOWS\system32> netsh interface portproxy add v4tov4 listenport=3000 connectport=3000 connectaddress=172.27.96.44
PS C:\WINDOWS\system32> netsh interface portproxy show all
Listen on ipv4: Connect to ipv4:
Address Port Address Port
--------------- ---------- --------------- ----------
* 3000 172.17.218.173 3000
It works, the target address is accesible. But when I run
netsh interface portproxy add v4tov4 listenport=3000 connectport=3000 connectaddress=$(wsl hostname -I)
PS C:\WINDOWS\system32> netsh interface portproxy show all
Listen on ipv4: Connect to ipv4:
Address Port Address Port
--------------- ---------- --------------- ----------
* 3000 172.27.96.44 3000
The target address is not accesible. It just doesn't respond. Even despite the fact that it is shown in the table. I tried string conversions e.g.
netsh interface portproxy add v4tov4 listenport=3000 connectport=3000 connectaddress=([string] (wsl hostname -I));
But it didn't help. Why it doesn't work even when the ip address is in the table?