Skip to content

Instantly share code, notes, and snippets.

@Rhynorater
Created January 25, 2023 19:05
Show Gist options
  • Save Rhynorater/477c815d7435792c367936577fdd2b6d to your computer and use it in GitHub Desktop.
Save Rhynorater/477c815d7435792c367936577fdd2b6d to your computer and use it in GitHub Desktop.
Quick little solution to add port forwarding to WSL on windows

Quick little solution to add port forwarding to WSL on windows

addPortForward.ps1

$port = $args[0]
netsh interface portproxy add v4tov4 listenport=$port listenaddress=0.0.0.0 connectport=$port connectaddress=(wsl bash ~/.getIP.sh)

=============

.getIP.sh

ip a | grep inet| grep eth0 | cut -f 6 -d " " | cut -f 1 -d "/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment