Проблема с настройкой экземпляра на aws ec2 в Ubuntu 18.04

#amazon-web-services #ubuntu #amazon-ec2 #server #instance

Вопрос:

Создал экземпляр на aws ec2, и сразу после начальной настройки все работает. Но через некоторое время (примерно на следующий день) сервер, похоже, теряет соединение с Интернетом. Я могу подключиться к нему, но я не могу загрузить никаких пакетов. Я также не могу выполнять запросы curl. Проблема решается только в том случае, если я создаю образ сервера, а затем создаю новую конфигурацию, но на следующий день проблема возвращается. Есть идеи, как решить эту проблему?

При создании экземпляра сетевые настройки были выбраны в качестве стандартных. Ubuntu 18.04

Пример вывода:

 apt update Err:1 http://security.ubuntu.com/ubuntu bionic-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 Err:2 http://eu-west-2.ec2.archive.ubuntu.com/ubuntu bionic InRelease   Could not connect to eu-west-2.ec2.archive.ubuntu.com:80 (54.229.225.193), connection timed out Could not connect to eu-west-2.ec2.archive.ubuntu.com:80 (54.246.214.20), connection timed out Could not connect to eu-west-2.ec2.archive.ubuntu.com:80 (34.253.229.19), connection timed out Could not connect to eu-west-2.ec2.archive.ubuntu.com:80 (34.241.117.189), connection timed out Could not connect to eu-west-2.ec2.archive.ubuntu.com:80 (54.229.116.227), connection timed out Could not connect to eu-west-2.ec2.archive.ubuntu.com:80 (34.253.189.82), connection timed out Err:3 http://eu-west-2.ec2.archive.ubuntu.com/ubuntu bionic-updates InRelease  Unable to connect to eu-west-2.ec2.archive.ubuntu.com:http: Err:4 http://eu-west-2.ec2.archive.ubuntu.com/ubuntu bionic-backports InRelease  Unable to connect to eu-west-2.ec2.archive.ubuntu.com:http: Reading package lists... Done Building dependency tree  Reading state information... Done 35 packages can be upgraded. Run 'apt list --upgradable' to see them. W: Failed to fetch http://eu-west-2.ec2.archive.ubuntu.com/ubuntu/dists/bionic/InRelease Could not connect to eu-west-2.ec2.archive.ubuntu.com:80 (54.229.225.193), connection timed out Could not connect to eu-west-2.ec2.archive.ubuntu.com:80 (54.246.214.20), connection timed out Could not connect to eu-west-2.ec2.archive.ubuntu.com:80 (34.253.229.19), connection timed out Could not connect to eu-west-2.ec2.archive.ubuntu.com:80 (34.241.117.189), connection timed out Could not connect to eu-west-2.ec2.archive.ubuntu.com:80 (54.229.116.227), connection timed out Could not connect to eu-west-2.ec2.archive.ubuntu.com:80 (34.253.189.82), connection timed out W: Failed to fetch http://eu-west-2.ec2.archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease Unable to connect to eu-west-2.ec2.archive.ubuntu.com:http: W: Failed to fetch http://eu-west-2.ec2.archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease Unable to connect to eu-west-2.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::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.  

Ответ №1:

Эта ошибка также может быть связана с DNS и не является необходимой для подключения к Интернету. Поскольку вы подключены к виртуальной машине по SSH, виртуальная машина имеет доступ в Интернет?

Я бы изменил DNS-серверы в resolv.conf. Что-то вроде этого подойдет:

 echo > /etc/resolv.conf <<EOF nameserver 1.0.0.1 nameserver 1.1.1.1 EOF  

Затем попробуйте еще раз, посмотрите, работает ли это.