【问题标题】:Problem with instance setup on aws ec2 on Ubuntu 18.04Ubuntu 18.04 上的 aws ec2 上的实例设置问题
【发布时间】:2021-12-01 19:16:42
【问题描述】:

在 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.

【问题讨论】:

    标签: amazon-web-services ubuntu amazon-ec2 server instance


    【解决方案1】:

    该错误也可能与 DNS 有关,而与 Internet 连接无关。既然你是通过 SSH 连接到虚拟机的,那么虚拟机就可以上网了吗?

    我会更改 resolv.conf 中的 DNS 服务器。这样的事情会做:

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

    然后再试一次,看看它是否有效。

    【讨论】:

      猜你喜欢
      • 2019-10-08
      • 1970-01-01
      • 2018-05-08
      • 2020-03-21
      • 2023-03-17
      • 1970-01-01
      • 2015-04-17
      • 2021-01-23
      • 2011-06-13
      相关资源
      最近更新 更多