@echo on
REM 先关闭虚拟子系统
wsl --shutdown
REM 把这里理解为一个开机启动脚本就行
wsl -d Ubuntu -u root ip addr del $(ip addr show eth0 ^| grep 'inet\b' ^| awk '{print $2}' ^| head -n 1) dev eth0
wsl -d Ubuntu -u root ip addr add 192.168.1.2/24 broadcast 192.168.1.255 dev eth0
wsl -d Ubuntu -u root ip route add 0.0.0.0/0 via 192.168.1.225 dev eth0
powershell -c "Get-NetAdapter 'vEthernet (WSL)' | Get-NetIPAddress | Remove-NetIPAddress -Confirm:$False; New-NetIPAddress -IPAddress 192.168.1.225 -PrefixLength 24 -InterfaceAlias 'vEthernet (WSL)'; Get-NetNat | ? Name -Eq WSLNat | Remove-NetNat -Confirm:$False; New-NetNat -Name WSLNat -InternalIPInterfaceAddressPrefix 192.168.1.0/24;"
REM 启动对应Linux系统,我这里是使用windows terminal
wt -p Ubuntu