欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 汽车 > 维修 > WSL子系统遇到网络不通报错Temporary failure resolving ‘archive.ubuntu.com‘

WSL子系统遇到网络不通报错Temporary failure resolving ‘archive.ubuntu.com‘

2025/6/15 10:30:42 来源:https://blog.csdn.net/weixin_44162814/article/details/148604416  浏览:    关键词:WSL子系统遇到网络不通报错Temporary failure resolving ‘archive.ubuntu.com‘

📌 解决方案

✅ 方法一:临时改 /etc/resolv.conf

在 WSL 里执行:

sudo bash -c "echo 'nameserver 8.8.8.8' > /etc/resolv.conf"

然后再执行:

sudo apt update sudo apt install htop

🔍 说明:

  • 8.8.8.8 是 Google 公共 DNS,国内用 223.5.5.5(阿里)或者 114.114.114.114 也行。


✅ 方法二:永久修复

  1. 禁止 WSL 自动生成 resolv.conf

sudo nano /etc/wsl.conf

添加:

[network] generateResolvConf = false

  1. 重启 WSL:

wsl --shutdown

然后再启动。

  1. 手动创建 resolv.conf:

sudo bash -c "echo 'nameserver 8.8.8.8' > /etc/resolv.conf" sudo chmod 644 /etc/resolv.conf


✅ 方法三:换国内源

如果 DNS 通了还是慢,可以把 apt 源也换成国内镜像:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak sudo nano /etc/apt/sources.list

换成:

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-updates main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-security main restricted universe multiverse

然后:

sudo apt update sudo apt install htop

📌 📢 总结

✔ 先修 resolv.conf,能通 DNS
✔ 必要时改 apt 源
✔ 然后就能顺利安装 htop 和其他包了

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词