创建wsl2-start.bat批处理文件

wsl -d Ubuntu-20.04 -u root /etc/init.wsl
# 指定发行版子系统,添加一个 eth0:1 网卡
# wsl -d Ubuntu-20.04 -u root ip addr add 172.20.20.20/20 broadcast 172.20.81.255 dev eth0 label eth0:1
# 在Win11中添加IP地址
netsh interface ip add address "vEthernet (WSL)" 172.20.20.80 255.255.255.0

Ubuntu中写入init.wsl文件

#ssh
/etc/init.d/ssh start
#network static ip
ip addr add 172.20.20.20/20 broadcast 172.20.81.255 dev eth0 label eth0:1
#bt
/etc/init.d/bt restart

固定wsl2的ip地址

创建wsl2-start.bat批处理文件的快捷方式,用Quicker进行快捷方式开机自启动