背景:
特殊原因使用wsl + vscode 开发python, 使用一段时间后突然无法上网了(dns解析失败), 宿主机能正常上网;
1 查看wsl配置
cat /etc/wsl.conf
[network]
generateResolvConf = false
2 查看wsl ip配置
3 查看路由信息,找到网关地址
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.21.32.1 0.0.0.0 UG 0 0 0 eth0
4 将网关地址配置到/etc/resolv.conf, 加上dns配置
cat /etc/resolv.conf
nameserver 172.21.32.1
nameserver 8.8.8.8
nameserver 8.8.4.4
5 测试 ping wwww.baidu.com
标签:0.0,wsl,etc,域名,conf,8.8,nameserver,解析,wsl2 From: https://www.cnblogs.com/gatling/p/18113032