Created
March 11, 2021 11:51
-
-
Save duboiss/7901b7abc339b7e48b8960340cc27404 to your computer and use it in GitHub Desktop.
WSL2 map port to host
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```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