Skip to content

Commit

Permalink
feat: Implement deletion script for WSL2 port forwarding rules (#20)
Browse files Browse the repository at this point in the history
Signed-off-by: Sean O'Hair <sean.ohair@intel.com>
  • Loading branch information
seanohair22 authored Sep 11, 2023
1 parent 4ca70cd commit 7bffaa4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions WSL_Port_Removal_Script.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
########################################################################
# Copyright (c) Intel Corporation 2023
# SPDX-License-Identifier: BSD-3-Clause
########################################################################

## NOTE: Run with Admin Powershell Terminal!

# WSL Port Forwarding Removal of Port 22 and 2223
netsh interface portproxy delete v4tov4 listenport=22 listenaddress=0.0.0.0
netsh interface portproxy delete v4tov4 listenport=2223 listenaddress=0.0.0.0

# WSL Remove firewall rules
netsh advfirewall firewall delete rule name="Open SSH port 22 for WSL2"
netsh advfirewall firewall delete rule name="Open SSH Tunnel port 2223 for WSL2"
2 changes: 1 addition & 1 deletion WSL_Port_Script.ps1 → WSL_Port_Setup_Script.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ echo "Ubuntu IP: $wsl_ip"
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=22 connectport=22 connectaddress=$wsl_ip
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=2223 connectport=2223 connectaddress=$wsl_ip
netsh interface portproxy show all
# WSL Add firewall rules

# WSL Add firewall rules
netsh advfirewall firewall add rule name="Open SSH Tunnel port 2223 for WSL2" dir=in action=allow protocol=TCP localport=2223
netsh advfirewall firewall add rule name="Open SSH port 22 for WSL2" dir=in action=allow protocol=TCP localport=22

0 comments on commit 7bffaa4

Please sign in to comment.