You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS EC2 t2.micro实例sudo apt install与wget连接失败求助

AWS EC2 t2.micro实例网络连接停滞问题排查

问题现象

在AWS EC2 t2.micro实例中执行以下操作时均出现连接停滞:

  1. 使用wget下载Tomcat安装包:
$ wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.67/bin/apache-tomcat-9.0.67.tar.gz
--2022-10-04 05:41:44--  https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.67/bin/apache-tomcat-9.0.67.tar.gz
Resolving dlcdn.apache.org (dlcdn.apache.org)... 151.101.2.132, 2a04:4e42::644
Connecting to dlcdn.apache.org (dlcdn.apache.org)|151.101.2.132|:443...
  1. 使用sudo apt install安装net-tools:
$ sudo apt install net-tools
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  net-tools
0 upgraded, 1 newly installed, 0 to remove and 22 not upgraded.
Need to get 196 kB of archives.
After this operation, 864 kB of additional disk space will be used.
0% [Connecting to us-east-1.ec2.archive.ubuntu.com (3.87.126.146)]

排查与解决步骤

  • 检查安全组出站规则
    确保实例关联的安全组允许TCP 80/443端口的出站流量到0.0.0.0/0,这是HTTPS/HTTP访问公网资源的基础。如果出站规则被限制,会直接导致无法建立连接。

  • 验证网络ACL配置
    检查实例所在子网的网络ACL,出站规则需允许80/443端口流量,且没有优先级更高的拒绝规则。网络ACL是子网级防火墙,需与安全组配合保证流量正常通行。

  • 测试基础连通性

    • 执行ping 8.8.8.8测试公网连通性,若无法ping通,说明实例无公网访问能力。
    • 执行nc -zv dlcdn.apache.org 443或telnet dlcdn.apache.org 443,验证特定端口的连接是否能建立,定位是端口问题还是整体网络问题。
  • 确认路由表配置
    检查实例所在子网的路由表,需包含指向Internet Gateway(IGW)的路由条目,目标地址为0.0.0.0/0,否则实例无法访问公网。

  • 检查公网IP分配
    确认实例已分配公网IP或弹性IP,无公网IP的实例无法直接访问公网资源,可通过AWS控制台查看实例网络属性。

  • 更换apt软件源(针对apt问题)
    若官方源连接缓慢,可修改/etc/apt/sources.list,将us-east-1.ec2.archive.ubuntu.com替换为其他稳定的Ubuntu源,比如区域内的镜像源,提升连接速度。

内容的提问来源于stack exchange,提问作者eastwater

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 07:10:32