某些索引檔下載失敗。它們已被忽略,或使用舊的。當 sudo apt update 使用 WSL 2 時

某些索引檔下載失敗。它們已被忽略,或使用舊的。當 sudo apt update 使用 WSL 2 時
$ 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

相關內容