某些索引文件下载失败。它们已被忽略,或使用旧文件代替。当使用 WSL 2 执行 sudo apt update 时

某些索引文件下载失败。它们已被忽略,或使用旧文件代替。当使用 WSL 2 执行 sudo apt update 时
$ sudo apt update
Err:1 http://archive.ubuntu.com/ubuntu focal InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://security.ubuntu.com/ubuntu focal-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
  • 系统:Windows 10 PRO 19044.1415

  • WSL 2,Ubuntu 20.04

ping到 google.com 也失败了:ping: google.com: Temporary failure in name resolution


已经完成了:

  • wsl.conf其中包含以下几行:
[network]
generateResolvConf = false
  • resolv.conf用几个重新创建nameserver
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 1.1.1.1

尝试过:

  • 添加nameserver 8.8.8.8wsl.conf。不起作用。
  • 保持单行nameserver在内resolv.conf
  • 关注这些步骤
  • New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow这里

问题已从 StackOverflow 替换

答案1

终于找到答案了。这甚至不是我的错...

这个建议帮了我大忙,sudo apt update终于成功了。如果你没有.wslconfig文件,就自己创建吧。

最终得到这个内部内容resolv.conf

nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 1.1.1.1
nameserver 208.67.222.222  # OpenDNS address
nameserver 192.168.0.10  # ipv4 address of your windows machine. *1

*1 -来源

答案2

我发现这与我的情况相关:

https://docs.microsoft.com/en-us/windows/wsl/troubleshooting#no-internet-access-in-wsl

我不得不关闭 Symantec Network Threat Protection

答案3

输入以下命令并运行。然后再次更新。

wget --no-check-certificate http.kali.org/kali/pool/main/k/kali-archive-keyring_2022.1_all.deb

相关内容