1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
@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
|