Updates Bridge-WslPorts.ps1

This commit is contained in:
2025-05-16 00:20:24 -03:00
parent 06f74c4068
commit a8139fd987

View File

@@ -1,6 +1,6 @@
# https://jwstanly.com/blog/article/Port+Forwarding+WSL+2+to+Your+LAN/ # https://jwstanly.com/blog/article/Port+Forwarding+WSL+2+to+Your+LAN/
$ports = @(80, 443, 25565); $ports = @(8080, 25565);
$wslAddress = bash.exe -c "ifconfig eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'" $wslAddress = bash.exe -c "ifconfig eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'"
@@ -20,9 +20,9 @@ foreach ($port in $ports) {
Invoke-Expression "netsh interface portproxy add v4tov4 listenport=$port listenaddress=$listenAddress connectport=$port connectaddress=$wslAddress"; Invoke-Expression "netsh interface portproxy add v4tov4 listenport=$port listenaddress=$listenAddress connectport=$port connectaddress=$wslAddress";
} }
# $fireWallDisplayName = 'WSL Port Forwarding'; $fireWallDisplayName = 'WSL Port Forwarding';
# $portsStr = $ports -join ","; $portsStr = $ports -join ",";
# Invoke-Expression "Remove-NetFireWallRule -DisplayName $fireWallDisplayName"; Invoke-Expression "Remove-NetFireWallRule -DisplayName '$fireWallDisplayName'";
# Invoke-Expression "New-NetFireWallRule -DisplayName $fireWallDisplayName -Direction Outbound -LocalPort $portsStr -Action Allow -Protocol TCP"; Invoke-Expression "New-NetFireWallRule -DisplayName '$fireWallDisplayName' -Direction Outbound -LocalPort $portsStr -Action Allow -Protocol TCP";
# Invoke-Expression "New-NetFireWallRule -DisplayName $fireWallDisplayName -Direction Inbound -LocalPort $portsStr -Action Allow -Protocol TCP"; Invoke-Expression "New-NetFireWallRule -DisplayName '$fireWallDisplayName' -Direction Inbound -LocalPort $portsStr -Action Allow -Protocol TCP";