Skip to content

Instantly share code, notes, and snippets.

@duboiss
Created March 11, 2021 11:51
Show Gist options
  • Save duboiss/7901b7abc339b7e48b8960340cc27404 to your computer and use it in GitHub Desktop.
Save duboiss/7901b7abc339b7e48b8960340cc27404 to your computer and use it in GitHub Desktop.
WSL2 map port to host
```ps
function mapport {
Param(
[parameter(Mandatory=$true)][int]$windowsPort,
[parameter(Mandatory=$true)][int]$wslPort
)
$ip = wsl hostname -I
netsh interface portproxy add v4tov4 listenport=$windowsPort listenaddress=0.0.0.0 connectport=$wslPort connectaddress=$ip
}
mapport 80 80
mapport 443 443
mapport 8000 8000
mapport 8080 8080
mapport 8081 8081
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment