60

WSL から WSL2 にアップグレードした後

sudo apt-get update

動作しなくなりました。後:

wsl --set-version Ubuntu-18.04 2

出力は次のとおりです。

> sudo apt-get update
Err:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Err:2 http://archive.ubuntu.com/ubuntu bionic InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

WSL1 に戻ると、問題は再び解消されます。Debianでも同じで、CentOSでも同様です..したがって、WSL2にはバグがあるはずです。

Windows10 ビルド バージョンは 19041 で、本日インストールされました。

WSL2 の回避策はありますか? よろしく

4

11 に答える 11

2

次のように変更して問題を解決し/etc/resolv.confました。

nameserver 8.8.8.8

その後

$ sudo chattr -f +i /etc/resolv.conf

実際には+i==immutable属性を持つファイルを「ロック」するため、OS によって再生成することはできません。このようにして、ユーザーが変更したもの/etc/resolv.confは永続的になります。

の作成が機能しないことがわかりました/etc/wsl.confが、とにかくそのままにしました:

[network]
generateResolvConf = false
于 2021-10-21T04:37:51.293 に答える