Skip to content

Instantly share code, notes, and snippets.

@stephenchew
Last active January 29, 2024 03:23
Show Gist options
  • Select an option

  • Save stephenchew/d60ddd3d55fe173ef7f810da2e80b6df to your computer and use it in GitHub Desktop.

Select an option

Save stephenchew/d60ddd3d55fe173ef7f810da2e80b6df to your computer and use it in GitHub Desktop.

Forward port from host to WSL

In PowerShell, run:

netsh interface portproxy add v4tov4 listenport=<host post> listenaddress=0.0.0.0 connectport=<wsl port> connectaddress=<wsl IP address>

e.g. forward port 8080 to port 8080

netsh interface portproxy add v4tov4 listenport=8080 listenaddress=0.0.0.0 connectport=8080 connectaddress=172.30.144.20

WSL IP Address

The actual IP address of the guest (not the gateway or whatsoever), can be obtained by commands like ip a.

List all forwarded ports

netsh interface portproxy show all

Delete forwarded port

netsh interface portproxy delete v4tov4 listenport=<host post> listenaddress=0.0.0.0

e.g. delete port 1234

netsh interface portproxy delete v4tov4 listenport=1234 listenaddress=0.0.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment