amazon-web-services - aws-vpc 容器无法访问互联网

标签 amazon-web-services amazon-ecs amazon-vpc

我在 AWS ECS 集群中创建了 ECS 服务。
我的容器使用 awsvpc 网络模式。该服务没有负载均衡器。

但它不能触及任何公共(public)互联网资源。

当我转到 ECS 实例并 ssh 进入 docker 容器时,我无法获取任何公共(public)资源。

root@ip-10-3-1-23:/app# traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
 1  * * *
 2  * * *
 3  * * *
 4  * * *
 5  * * *
 6  *^C
root@ip-10-3-1-23:/app# wget google.com
--2019-08-31 22:34:38--  http://google.com/
Resolving google.com (google.com)... 172.217.9.206, 2607:f8b0:4004:807::200e
Connecting to google.com (google.com)|172.217.9.206|:80... ^C
root@ip-10-3-1-23:/app# 

EC2 实例安全组:

入境:
Type            Protocol        Port Range      Source                      Description
All TCP         TCP             0 - 65535       10.3.0.0/16     
SSH             TCP             22              sg-5c260123 (mgmt-bastion)  
Custom TCP Rule TCP             51678           sg-0784b8f53ab37c234 (mgmt-jenkins-sg)

出境:
Type            Protocol        Port Range      Source                      Description
All traffic     All             All             0.0.0.0/0

服务安全组:

入境:
Type            Protocol        Port Range      Source                      Description
All TCP         TCP             0 - 65535       10.3.0.0/16

出境:
Type            Protocol        Port Range      Source                      Description
All traffic     All             All             0.0.0.0/0

你能帮我调试一下吗,请问如何允许互联网访问?

最佳答案

来自 AWS Documentation :

The awsvpc network mode does not provide task ENIs with public IP addresses for tasks that use the EC2 launch type. To access the internet, tasks that use the EC2 launch type must be launched in a private subnet that is configured to use a NAT gateway. For more information, see NAT Gateways in the Amazon VPC User Guide. Inbound network access must be from within the VPC using the private IP address or DNS hostname, or routed through a load balancer from within the VPC. Tasks launched within public subnets do not have outbound network access.

关于amazon-web-services - aws-vpc 容器无法访问互联网,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57741475/

相关文章:

java - 读取/更新操作时出现 Dynamodb ConditionalCheckFailedException - java sdk

amazon-web-services - 如果尚未创建,如何创建 AWS Cloud Formation 条件来创建新的 SSM 参数?

amazon-web-services - 已删除 Cloudformation 堆栈,由于资源已存在,现在无法重新创建新的 Cloudformation 堆栈

amazon-web-services - 从无公网 IP 地址的 AWS VPC 实例访问 Internet

amazon-web-services - 在 ELB 后面的 VPC 中调用 AWS Elastic Beanstalk 服务器的首次加载时间非常慢

amazon-web-services - 如何通过 AWS SAM 模板创建具有自动缩放吞吐量的 DynamoDB 表

amazon-web-services - 从 Lambda 访问 S3 时出现 InvalidToken 错误

amazon-web-services - 调用 UpdateService 操作时的 AWS ECS InvalidParameterExcpetion

jenkins - 在 Jenkins 上使用 Groovy 配置 amazon-ecs slave 插件

node.js - VPC 内 Lambda 的 SQS 超时