Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Get the IP address of your WSL2 instance
- $wslIP = bash.exe -c "hostname -I"
- if ($wslIP) {
- Write-Host "WSL2 IP Address: $wslIP"
- # List of ports to forward (host ports from your docker-compose.yml)
- $ports = @(
- 80, # Traefik HTTP
- 443, # Traefik HTTPS
- 32400, # Plex
- 8989, # Sonarr
- 7878, # Radarr
- 9696, # Prowlarr
- 8096, # Jellyfin
- 8920, # Jellyfin HTTPS (if configured)
- 8080, # Heimdall (HTTP - internal to WSL2)
- 8443, # Heimdall (HTTPS)
- 5055, # Jellyseerr
- 8181, # Tautulli
- 5056, # Overseerr
- 19999, # Netdata
- 3000, # MeshCentral HTTP
- 3001, # MeshCentral HTTPS
- 8080, # rdtclient
- 9117 # Jackett
- )
- foreach ($port in $ports) {
- $ruleNameHTTP = "WSL2_Forward_TCP_$port"
- $ruleNameUDP = "WSL2_Forward_UDP_$port"
- # Forward TCP port
- netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=$port connectaddress=$wslIP connectport=$port protocol=tcp
- if ($LASTEXITCODE -eq 0) {
- Write-Host "Successfully forwarded TCP port $port"
- } else {
- Write-Warning "Failed to forward TCP port $port. Rule '$ruleNameHTTP' might already exist. Try running 'netsh interface portproxy delete v4tov4 listenport=$port protocol=tcp'"
- }
- # Forward UDP port (if applicable - check your container configurations)
- if ($port -eq 8324 -or $port -eq 32410 -or $port -eq 32412 -or $port -eq 32413 -or $port -eq 32414 -or $port -eq 1900 -or $port -eq 7359) {
- netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=$port connectaddress=$wslIP connectport=$port protocol=udp
- if ($LASTEXITCODE -eq 0) {
- Write-Host "Successfully forwarded UDP port $port"
- } else {
- Write-Warning "Failed to forward UDP port $port. Rule '$ruleNameUDP' might already exist. Try running 'netsh interface portproxy delete v4tov4 listenport=$port protocol=udp'"
- }
- }
- }
- } else {
- Write-Error "Could not retrieve WSL2 IP address. Make sure WSL2 is running."
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement