Skip to content

Commit

Permalink
修复:重启服务器后,添加映射端口不是最新内网IP问题
Browse files Browse the repository at this point in the history
Signed-off-by: 邓小明 <[email protected]>
  • Loading branch information
hhun authored and gitee-org committed Dec 30, 2022
1 parent f9712a4 commit d958e9d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion wsl-server-manage.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setlocal EnableDelayedExpansion & cd /d "%~dp0"

SET WSL_TITLE=WSL子系统服务器管理 v1.3
SET WSL_TITLE=WSL子系统服务器管理 v1.4
SET WSL_SYSTEM= Ubuntu-20.04

SET PORT_LIST=20,21,22,80,888,8888,8324
Expand Down Expand Up @@ -139,6 +139,9 @@ goto first

:do_add_wsl_mapping
@echo #################### 添加WSL端口映射 Start ####################
for /f "tokens=1" %%i in ('arp -a^|findstr "172.*动态"') do (
set wsl_ip=%%i
)
for %%i in (%PORT_LIST%) do (
cmd /c "echo netsh interface portproxy add v4tov4 listenport=%%i listenaddress=* connectport=%%i connectaddress=%wsl_ip%"
cmd /c "netsh interface portproxy add v4tov4 listenport=%%i listenaddress=* connectport=%%i connectaddress=%wsl_ip%"
Expand Down

0 comments on commit d958e9d

Please sign in to comment.