【WSL2】WSL2로 우분투를 움직이면 빠진 건 (sudo apt-get update 할 수 없다)

2021/06/19 토요일

Introduction



WSL2에서 Ubuntu-20.04를 즐겨 보았습니다.
그 때에 빠진 일에 대해 기사로 둡니다.
도움이되면 다행입니다.

What to do?



다음 작업을 수행했습니다.
  • Windows 10 업데이트(20H1)
  • WSL2 설치
  • Ubuntu-20.04 설치
  • Docker Desktop for Windows 설치
  • Ubuntu-20.04에서 sudo apt-get update ← 문제 발생

  • (사건 1) Ubuntu-20.04 기동 직후에 sudo apt-get update 할 수 없다



    (전제) Windows 10은 Wi-Fi 액세스 포인트 경유로 인터넷에 접속하고 있었다.

    원인



    WSL2의 가상 네트워크 어댑터 vEthernet (WSL)가 인터넷에 연결되지 않았습니다.

    해결



    Wi-Fi 네트워크 어댑터 공유를 활성화합니다.

    네트워크의 다른 사용자가이 컴퓨터의 인터넷 연결을 통한 연결을 허용합니다.



    (사건 2) 이름 해석을 할 수 없다


    host google.com
    

    사건 1을 해결했지만. .
    위의 명령으로 이름을 확인할 수 없습니다.

    원인



    Linux 컨테이너 (Ubuntu)의 resolv.conf에서 컨테이너 내의 IP 주소가 설정되었습니다.
    따라서 이름 해석이 불가능하고 apt-get이 실패했습니다.

    해결


    /etc/resolv.comfnameserver 8.8.8.8 추가
    sudo rm /etc/resolv.conf
    sudo sh -c "echo 'nameserver 8.8.8.8' > /etc/resolv.conf"
    host google.com
    

    (사건 3) sudo apt-get update에서 Err :이 표시됩니다.



    사건 1, 사건 2를 해결했지만. .
    fetch가 실패합니다.
    $ sudo apt-get update
    Err:1 http://archive.ubuntu.com/ubuntu focal InRelease
      Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out
    Err:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease
      Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable)
    Err:3 http://archive.ubuntu.com/ubuntu focal-backports InRelease
      Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable)
    Err:4 http://security.ubuntu.com/ubuntu focal-security InRelease
      Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out
    Reading package lists... Done
    W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed outW: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable)
    W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease  Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to archive.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable)
    W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease  Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::18). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out
    W: Some index files failed to download. They have been ignored, or old ones used instead.
    

    원인



    바이러스 소프트의 방화벽이 방해하고 있었다.
  • 제 경우에는 Symantec Endpoint Protection이 방해를 받았습니다.

  • 해결



    방화벽 기능을 일시적으로 비활성화합니다.



    Conclusion



    WSL2의 Ubuntu-20.04 컨테이너의 네트워크 메커니즘은 Linux만큼 솔직하지 않을 것입니다.
    우분투 머신에서 리눅스 컨테이너를 설정했을 때 아무 문제없이 작동했습니다.

    뭔가 도움이되면 다행입니다. 👍

    (了)

    좋은 웹페이지 즐겨찾기