# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf: # [network] # generateResolvConf = false nameserver 172.30.80.1
原来可以通过/etc/wsl.conf文件来控制这个文件的生成……
其实现在的需求就是让 WSL2 内部恢复连网并保持,不需要频繁折腾的话固不固定 IP 都无所谓,尤其vEthernet (WSL)怎么命令行配置也不懂;
1 2 3 4 5 6 7 8 9 10 11 12 13
# 配置 WSL2 内部的网络,并写入配置文件 # 给 WSL2 设置静态 IP 地址 - 知乎 # https://zhuanlan.zhihu.com/p/380779630 sudo ip addr del $(ip addr show eth0 | grep 'inet\b' | awk '{print $2}' | head -n 1) dev eth0 sudo ip addr add 192.168.50.2/24 broadcast 192.168.50.255 dev eth0 sudo ip route add 0.0.0.0/0 via 192.168.50.1 dev eth0 sudo echo nameserver 192.168.50.1 > /etc/resolv.conf
# Using PowerShell to Set Static and DHCP IP Addresses – Part 1 | PDQ # https://www.pdq.com/blog/using-powershell-to-set-static-and-dhcp-ip-addresses-part-1/