WSLでインターネットに接続できない。

file

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.

これは通常、DNSの解決に問題があることを示しています。つまり、ネームサーバーが正しく機能していない可能性があります。この問題を解決するためには、ネームサーバーの設定を見直す必要があります。

解決法(ネームサーバーの設定を変える)

sudo nano /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4

再起動時に設定が消えないようにする

sudo nano /etc/wsl.conf
[network]
generateResolvConf = false

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です