@echo "waiting 15s to timeout"
:: timeout /T 15
waitfor SomethingThatIsNeverHappening /t 15
@echo begin to start wsl...
@echo off
setlocal enabledelayedexpansion
::先停掉可能在跑的wsl实例
wsl --shutdown
if !errorlevel! equ 0 (
::检查WSL有没有我需要的IP
wsl -u root ip addr | findstr "192.168.3.100" > nul
if !errorlevel! equ 0 (
echo wsl ip has set
) else (
::IP不存在则绑定IP
wsl -u root ip addr add 192.168.3.100/24 broadcast 192.168.3.255 dev eth0 label eth0:1
echo set wsl ip success: 192.168.3.100
)
::检查宿主机有没有我需要的IP
ipconfig | findstr "192.168.3.200" > nul
if !errorlevel! equ 0 (
echo windows ip has set
) else (
::IP不存在则绑定IP
netsh interface ip add address "vEthernet (WSL)" 192.168.3.200 255.255.255.0
echo set windows ip success: 192.168.3.200
)
)
::为主机设置SSH转发端口
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=22 connectaddress=192.168.3.100 connectport=22
:: 启动wsl
wsl nohup sh -c "sleep 108000 & <nul > nul 2>&1"
:: pause
【 在 stub 的大作中提到: 】
: 求脚本
--
FROM 111.193.237.*