ubuntu@ip-root:~$ sudo apt-get update Err:1 http://security.ubuntu.com/ubuntu bionic-security InRelease Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) 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:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to security.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to security.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out Err:2 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu bionic InRelease Could not connect to ap-northeast-1.ec2.archive.ubuntu.com:80 (54.199.72.88), connection timed out Could not connect to ap-northeast-1.ec2.archive.ubuntu.com:80 (54.248.7.22), connection timed out Could not connect to ap-northeast-1.ec2.archive.ubuntu.com:80 (54.248.22.77), connection timed out Could not connect to ap-northeast-1.ec2.archive.ubuntu.com:80 (54.248.192.197), connection timed out Could not connect to ap-northeast-1.ec2.archive.ubuntu.com:80 (54.248.204.122), connection timed out Could not connect to ap-northeast-1.ec2.archive.ubuntu.com:80 (54.168.13.207), connection timed out Could not connect to ap-northeast-1.ec2.archive.ubuntu.com:80 (54.168.29.123), connection timed out Err:3 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu bionic-updates InRelease Unable to connect to ap-northeast-1.ec2.archive.ubuntu.com:http: Err:4 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu bionic-backports InRelease Unable to connect to ap-northeast-1.ec2.archive.ubuntu.com:http: Reading package lists... Done W: Failed to fetch http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu/dists/bionic/InRelease Could not connect to ap-northeast-1.ec2.archive.ubuntu.com:80 (54.199.72.88), connection timed out Could not connect to ap-northeast-1.ec2.archive.ubuntu.com:80 (54.248.7.22), connection timed out Could not connect to ap-northeast-1.ec2.archive.ubuntu.com:80 (54.248.22.77), connection timed out Could not connect to ap-northeast-1.ec2.archive.ubuntu.com:80 (54.248.192.197), connection timed out Could not connect to ap-northeast-1.ec2.archive.ubuntu.com:80 (54.248.204.122), connection timed out Could not connect to ap-northeast-1.ec2.archive.ubuntu.com:80 (54.168.13.207), connection timed out Could not connect to ap-northeast-1.ec2.archive.ubuntu.com:80 (54.168.29.123), connection timed out W: Failed to fetch http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease Unable to connect to ap-northeast-1.ec2.archive.ubuntu.com:http: W: Failed to fetch http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease Unable to connect to ap-northeast-1.ec2.archive.ubuntu.com:http: W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1562::15). - connect (101: Network is unreachable) 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:1360:8001::23). - connect (101: Network is unreachable) Cannot initiate the connection to security.ubuntu.com:80 (2001:67c:1360:8001::24). - connect (101: Network is unreachable) Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to security.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to security.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out W: Some index files failed to download. They have been ignored, or old ones used instead.
なんで?原因がわからない。
いろいろググってみたら/etc/apt/sources.listを
#deb http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu/ bionic main restricted deb http://archive.ubuntu.com/ubuntu/ bionic main restricted
に変更しろとか書かれていたので変更したが駄目。一応rebootしてみたが同じだった。
ちなみにWPは普通にアップデートできるしプラグインの更新もできる。wgetでデータのダウンロードもできる。
ターミナルからping archive.ubuntu.comもできるし、EC2ではないブラウザでアクセスもできる。なんでapt-getできないのだろう?
なのでまずpingでec2からplusload.netへ通信できるか確認してみる。
root@ip-:~# ping plusload.net PING plusload.net (126.201.138.101) 56(84) bytes of data. 64 bytes from 126.201.138.101: icmp_seq=1 ttl=46 time=12.7 ms 64 bytes from 126.201.138.101: icmp_seq=2 ttl=46 time=12.8 ms 64 bytes from 126.201.138.101: icmp_seq=3 ttl=46 time=12.9 ms 64 bytes from 126.201.138.101: icmp_seq=4 ttl=46 time=12.6 ms ^C --- 126.201.138.101 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3006ms rtt min/avg/max/mdev = 12.682/12.809/12.948/0.169 ms
できるのを確認。続いてhttps://repogen.simplylinux.ch/でsources.listを新しく作ってみてcurlでgetしてみる。
この12項目にチェック入れていればいい。
root@ip-:~# curl https://repogen.simplylinux.ch/txt/bionic/sources_a 58947ded61f99f7fe3be285f747abc7b8740dfa.txt #------------------------------------------------------------------------------# # OFFICIAL UBUNTU REPOS # #------------------------------------------------------------------------------# ###### Ubuntu Main Repos deb http://jp.archive.ubuntu.com/ubuntu/ bionic main restricted universe multive rse deb-src http://jp.archive.ubuntu.com/ubuntu/ bionic main restricted universe mul tiverse ###### Ubuntu Update Repos deb http://jp.archive.ubuntu.com/ubuntu/ bionic-security main restricted univers e multiverse deb http://jp.archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://jp.archive.ubuntu.com/ubuntu/ bionic-security main restricted uni verse multiverse deb-src http://jp.archive.ubuntu.com/ubuntu/ bionic-updates main restricted univ erse multiverse
オッケー,GETできる。通信はINもOUTも問題ないようだ。
なのでこちらで日本のUbuntuリポジトリのサーバをec2からアクセスできるかチェックしてみる。
まずはhttp://jp.archive.ubuntu.com/ubuntuをec2から見えるかチェック。
root@ip-:~# nc -v -w 1 jp.archive.ubuntu.com -z 80 nc: connect to jp.archive.ubuntu.com port 80 (tcp) timed out: Operation now in p rogress root@ip-172-31-39-46:~# nc -v -w 1 archive.ubuntu.com -z 80 nc: connect to archive.ubuntu.com port 80 (tcp) timed out: Operation now in prog ress nc: connect to archive.ubuntu.com port 80 (tcp) timed out: Operation now in prog ress nc: connect to archive.ubuntu.com port 80 (tcp) failed: Network is unreachable nc: connect to archive.ubuntu.com port 80 (tcp) failed: Network is unreachable nc: connect to archive.ubuntu.com port 80 (tcp) failed: Network is unreachable nc: connect to archive.ubuntu.com port 80 (tcp) failed: Network is unreachable
jpも本家もだめみたい。なので日本のもののリポジトリミラーサーバをチェックしてみる。
root@ip-:~# nc -v -w 1 ubuntutym.u-toyama.ac.jp/ -z 80 nc: getaddrinfo for host "ubuntutym.u-toyama.ac.jp/" port 80: Name or service not known root@ip-172-31-39-46:~# nc -v -w 1 ubuntutym.u-toyama.ac.jp -z 80 nc: connect to ubuntutym.u-toyama.ac.jp port 80 (tcp) timed out: Operation now in progress root@ip-172-31-39-46:~# nc -v -w 1 ftp.riken.go.jp -z 80 nc: connect to ftp.riken.go.jp port 80 (tcp) timed out: Operation now in progress root@ip-172-31-39-46:~# nc -v -w 1 ftp.riken.go.jp -z 21 Connection to ftp.riken.go.jp 21 port [tcp/ftp] succeeded!
あれ、80は駄目だけど21のftpなら成功するぞ。ということで理研のftpに書き換えしてみる。
"/etc/apt/sources.list" 15L, 855C 15,0-1 All #------------------------------------------------------------------------------# # OFFICIAL UBUNTU REPOS # #------------------------------------------------------------------------------# Ubuntu Main Repos deb ftp:///ftp.riken.go.jp/Linux/ubuntu/ bionic main restricted universe multiverse deb-src ftp://ftp.riken.go.jp/Linux/ubuntu/ bionic main restricted universe multiverse ###### Ubuntu Update Repos deb ftp://ftp.riken.go.jp/Linux/ubuntu/ bionic-security main restricted universe multiverse deb ftp://ftp.riken.go.jp/Linux/ubuntu/ bionic-updates main restricted universe multiverse deb-src ftp://ftp.riken.go.jp/Linux/ubuntu/ bionic-security main restricted universe multiverse deb-src ftp://ftp.riken.go.jp/Linux/ubuntu/ bionic-updates main restricted universe multiverse
一部失敗するがおおむねGETできた!なので他のftpに変更してみる。
"/etc/apt/sources.list" 15L, 850C 8,9 All #------------------------------------------------------------------------------# # OFFICIAL UBUNTU REPOS # #------------------------------------------------------------------------------# ###### Ubuntu Main Repos deb ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu/ bionic main restricted universe multiverse deb-src ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu/ bionic main restricted universe multiverse ###### Ubuntu Update Repos deb ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu/ bionic-security main restricted universe multiverse deb ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu/ bionic-updates main restricted universe multiverse deb-src ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu/ bionic-security main restricted universe multiverse deb-src ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu/ bionic-updates main restricted universe multiverse
北陸先端科学技術大学院大学のftpに書き換えたらすべて成功したぞ!
root@ip-:~# apt-get update Get:1 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic InRelease [242 kB] Get:2 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-security InRelease [88.7 kB] Get:3 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-updates InRelease [88.7 kB] Get:4 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic/multiverse Sources [181 kB] Get:5 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic/main Sources [829 kB] Get:6 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic/universe Sources [9051 kB] Get:7 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic/restricted Sources [5324 B] Get:8 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic/main amd64 Packages [1019 kB] Get:9 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic/main Translation-en [516 kB] Get:10 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic/restricted amd64 Packages [9184 B] Get:11 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic/restricted Translation-en [3584 B] Get:12 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic/universe amd64 Packages [8570 kB] Get:13 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic/universe Translation-en [4941 kB] Get:14 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic/multiverse amd64 Packages [151 kB] Get:15 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic/multiverse Translation-en [108 kB] Get:16 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-security/universe Sources [264 kB] Get:17 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-security/restricted Sources [11.4 kB] Get:18 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-security/main Sources [234 kB] Get:19 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-security/multiverse Sources [4148 B] Get:20 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-security/main amd64 Packages [1355 kB] Get:21 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-security/main Translation-en [269 kB] Get:22 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-security/restricted amd64 Packages [151 kB] Get:23 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-security/restricted Translation-en [20.4 kB] Get:24 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-security/universe amd64 Packages [1069 kB] Get:25 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-security/universe Translation-en [239 kB] Get:26 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-security/multiverse amd64 Packages [12.3 kB] Get:27 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-security/multiverse Translation-en [2908 B] Get:28 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-updates/multiverse Sources [10.4 kB] Get:29 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-updates/restricted Sources [15.9 kB] Get:30 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-updates/main Sources [494 kB] Get:31 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-updates/universe Sources [429 kB] Get:32 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-updates/main amd64 Packages [1681 kB] Get:33 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-updates/main Translation-en [360 kB] Get:34 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-updates/restricted amd64 Packages [169 kB] Get:35 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-updates/restricted Translation-en [23.0 kB] Get:36 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-updates/universe amd64 Packages [1671 kB] Get:37 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-updates/universe Translation-en [351 kB] Get:38 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-updates/multiverse amd64 Package s [30.8 kB] Get:39 ftp://ftp.jaist.ac.jp/pub/Linux/ubuntu bionic-updates/multiverse Translation-en [6920 B] Fetched 34.7 MB in 11s (3071 kB/s) Reading package lists... Done
何故だかわからないが80番は駄目で21番はOKだった。
今回の現象のまとめ:AWS、EC2のUbuntu18.04.5では何故か突然httpでのapt getができなくなったがリポジトリのURLをftpに変更したらアクセス出来てapt updateできるようになった。なのでaptが使えなくなったらまず、リポジトリのURLの状態をチェックしてみる事をお勧めします。
※いろいろ調べてみたらHTTP(80)以外は全て通信できました。なぜかHTTPだけ出られない。何故だろう?
今回の原因はAWSの設定に問題があるかと思ってEC2、VPCと見直したがhttpが制限されててftpが許可されているといった項目はみつからなかった。また、ftpについてはインバウンドもアウトバウンドも許可してないのでなんでftpのリポジトリがOKでhttpがダメなのかわからなかった。
また、もう一台Ubuntu18.04.5が手元にあるのだが、こちらではAWSで駄目だったjpも本家も正常にupdateできている。