第一步:修改 /etc/wsl.conf
vim /etc/wsl.conf
填入以下代码:
[network] generateResolvConf = false
第二步:修改/etc/resolv.conf
vim /etc/resolv.conf
填入以下代码:
# 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 8.8.8.8 nameserver 114.114.114.114
第三步:重启wsl
直接重启电脑即可,或者打开cmd输入以下代码:
wsl --shutdown