WSL and Powershell Ports

Connecting to WSL from Windows

In WSL

$ nc -l 8080
hello world

In Powershell

$ ncat 127.0.0.1 8080
$ hello world

In WSL the nc -l 8080 command listens on port 8080 for any incoming data, then prints it to the screen. In Powershell ncat 127.0.0.1 8080 sends everything you type to port 8080. You should see what you type both in the Powershell terminal and in the WSL terminal. Alternately you can open your browser and enter http://127.0.0.1:8080/ into your URL bar, and the WSL terminal will print out the HTML request.

Connecting to Windows from WSL

Install windows version of ncat [direct link] from https://nmap.org/.

In Powershell

$ ncat -l 8080
hello world

In WSL

$ cat /etc/resolv.conf
nameserver 172.59.192.1

$ nc 172.59.192.1 8080
$ hello world