LoginSignup
0
2

More than 1 year has passed since last update.

WSL2でNetwork is unreachableになる

Posted at

はじめに

サブPCのWindowsで、WSL2のUbuntuにTerraformをインストールしようと試みていました。

https://learn.hashicorp.com/tutorials/terraform/install-cli
ここのLinux版の手順の通り進めていたところ、

$ sudo apt-get update
Err:1 http://ppa.launchpad.net/ansible/ansible/ubuntu focal InRelease
  Cannot initiate the connection to ppa.launchpad.net:80 (2001:67c:1560:8008::19). - connect (101: Network is unreachable) Could not connect to ppa.launchpad.net:80 (91.189.95.85), connection timed out

このようにapt-get updateでNetwork is unreachableというエラーが出てしまいました。

どこが問題だったか

結論から言うと私の場合ファイアウォールでした。
あるあるですね。

いつだって不可解な動きの裏にはファイアウォールがいます。

きっと接続先からこちらへの通信をファイアウォールが遮断することでコネクションが確立できず、結果Network is unreachableということになってしまうのでしょう。

Symantec Endpoint Protectionの場合の設定変更

私のPCにはSymantec Endpoint Protectionが入っていたので、こいつの設定を変更しました。

  1. まずはSymantec Endpoint Protectionを開きます。
    capture53.png

  2. ネットワークとホストのエクスプロイト緩和機能のオプションから、設定の変更を選びましょう。

  3. ファイアウォールタブを選び、「不一致IPトラフィックの設定」という項目を確認してみましょう。
    ここが画像のように「アプリケーショントラフィックのみを許可する」になっていたら変更が必要です。

capture54.png

  1. 「IPトラフィックを許可する」にチェックを入れて「OK」すれば完了です。

他のファイアウォールでもきっと同じような設定項目があるはずなので、
適宜調べて変更してみてください。

他の解決策について

「WSL Network is unreachable」
などで調べると現在真っ先に出てくるのが以下のstackoverflowです。

ここで書かれている解決策はざっくりいうと、

  • wsl --shutdownでwslを再起動しろ
  • Ubuntu側の/etc/resolv.confなど諸々を修正しろ

といったことでした。

それらで解決したという人もいるみたいなので、ファイアウォールの設定を変更しても解決しない場合はこちらを試してみる価値はあるかと思います。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2