Files
R-clone-setup/lan-forward.ps1

21 lines
1.0 KiB
PowerShell

# Forwards Windows :8000 -> WSL collector, so LAN machines can reach the dashboard.
# RUN AS ADMINISTRATOR. Re-run after every Windows reboot (WSL's IP changes).
# Later: nginx replaces this by listening on Windows/LAN directly and proxying
# to the same target.
$wslIp = (wsl hostname -I).Trim().Split()[0]
Write-Host "WSL IP is $wslIp"
# refresh the port forward (delete old rule if present, then add)
netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport=8000 2>$null
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=8000 connectaddress=$wslIp connectport=8000
# firewall rule (only created once)
if (-not (Get-NetFirewallRule -DisplayName "Rclone Monitor 8000" -ErrorAction SilentlyContinue)) {
New-NetFirewallRule -DisplayName "Rclone Monitor 8000" -Direction Inbound -Protocol TCP -LocalPort 8000 -Action Allow | Out-Null
Write-Host "Firewall rule created."
}
netsh interface portproxy show v4tov4
Write-Host "`nDone. Dashboard now reachable on this PC's LAN IP, port 8000."