WSL2--DNS解析问题解决
1.问题
xurong@DESKTOP-SOE9MG1:~/.ssh$ sudo apt update
Ign:1 http://security.ubuntu.com/ubuntu noble-security InRelease
Ign:2 http://archive.ubuntu.com/ubuntu noble InRelease
Ign:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease
Ign:4 http://archive.ubuntu.com/ubuntu noble-backports InRelease
Ign:2 http://archive.ubuntu.com/ubuntu noble InRelease
Ign:1 http://security.ubuntu.com/ubuntu noble-security InRelease
Ign:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease
Ign:4 http://archive.ubuntu.com/ubuntu noble-backports InRelease
Ign:2 http://archive.ubuntu.com/ubuntu noble InRelease
Ign:1 http://security.ubuntu.com/ubuntu noble-security InRelease
Ign:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease
Ign:4 http://archive.ubuntu.com/ubuntu noble-backports InRelease
Err:2 http://archive.ubuntu.com/ubuntu noble InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:1 http://security.ubuntu.com/ubuntu noble-security InRelease
Temporary failure resolving 'security.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu noble-backports InRelease
Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
5 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/noble/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/noble-updates/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/noble-backports/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/noble-security/InRelease Temporary failure resolving 'security.ubuntu.com'
xurong@DESKTOP-SOE9MG1:~/.ssh$ sudo apt update
Ign:1 http://security.ubuntu.com/ubuntu Nobel-security InRelease
Ign:2 http://archive.ubuntu.com/ubuntu 高贵的 InRelease
Ign:3 http://archive.ubuntu.com/ubuntu Nobel-updates InRelease
Ign:4 http://archive.ubuntu.com/ubuntu Nobel-backports InRelease
Ign:2 http://archive.ubuntu.com/ubuntu 高贵的 InRelease
Ign:1 http://security.ubuntu.com/ubuntu Nobel-security InRelease
Ign:3 http://archive.ubuntu.com/ubuntu Nobel-updates InRelease
Ign:4 http://archive.ubuntu.com/ubuntu Nobel-backports InRelease
Ign:2 http://archive.ubuntu.com/ubuntu 高贵的 InRelease
Ign:1 http://security.ubuntu.com/ubuntu Nobel-security InRelease
Ign:3 http://archive.ubuntu.com/ubuntu Nobel-updates InRelease
Ign:4 http://archive.ubuntu.com/ubuntu Nobel-backports InRelease
错误:2 http://archive.ubuntu.com/ubuntu 高贵的 InRelease
暂时无法解析“archive.ubuntu.com”
错误:1 http://security.ubuntu.com/ubuntu Nobel-security InRelease
暂时无法解析“security.ubuntu.com”
错误:3 http://archive.ubuntu.com/ubuntu Nobel-updates InRelease
暂时无法解析“archive.ubuntu.com”
错误:4 http://archive.ubuntu.com/ubuntu Nobel-backports InRelease
暂时无法解析“archive.ubuntu.com”
正在阅读包裹清单...完成
构建依赖树...完成
读取状态信息...完成
可以升级5个包。运行“apt list --upgradable”来查看它们。
W:无法获取 http://archive.ubuntu.com/ubuntu/dists/noble/InRelease 解决“archive.ubuntu.com”临时失败
W:无法获取 http://archive.ubuntu.com/ubuntu/dists/noble-updates/InRelease 解决“archive.ubuntu.com”临时失败
W:无法获取 http://archive.ubuntu.com/ubuntu/dists/noble-backports/InRelease 解决“archive.ubuntu.com”临时失败
W:无法获取 http://security.ubuntu.com/ubuntu/dists/noble-security/InRelease 解决“security.ubuntu.com”临时失败
2.解决问题
临时更改 DNS 服务器:您可以临时将 DNS 服务器更改为公共 DNS 服务器,例如 Google(8.8.8.8 和 8.8.4.4)或 Cloudflare (1.1.1.1)。为此,请编辑 /etc/resolv.conf 文件
xurong@DESKTOP-SOE9MG1:/etc$ sudo vim /etc/resolv.conf
xurong@DESKTOP-SOE9MG1:/etc$ sudo rm /etc/resolv.conf
xurong@DESKTOP-SOE9MG1:/etc$ sudo touch /etc/resolv.conf
xurong@DESKTOP-SOE9MG1:/etc$ sudo vim resolv.conf
xurong@DESKTOP-SOE9MG1:/etc$ more resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
如果resolv.conf是一个链接文件,需要先将其删除,然后在创建添加内容