Advertisement
tracins

Wsl ip automation script

Apr 6th, 2025
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Get WSL2 IP
  2. $wslIp = wsl.exe -e "ip addr show eth0 | grep 'inet ' | awk '{print $2}' | cut -d '/' -f 1"
  3.  
  4. # Remove existing rule
  5. netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport=9443
  6.  
  7. # Add new rule with updated IP
  8. netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=9443 connectaddress=$wslIp connectport=9443
  9.  
  10. Write-Host "Port 9443 forwarded to WSL2 IP: $wslIp"
  11.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement