ec2 实例无法在没有弹性 IP 地址的情况下访问公共子网中的 Internet? [英] The ec2 instance can't access internet in a public subnet without a elastic ip address?

查看:59
本文介绍了ec2 实例无法在没有弹性 IP 地址的情况下访问公共子网中的 Internet?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 aws 上工作.我创建了一个公共子网,它的网络 ACL 允许所有网络流量,并与路由表中的互联网网关相关联.

I working on aws. I created a public subnet which has a network ACL allows all net traffic, and associated with a internet gateway in the route table.

然后我创建了一个没有弹性ip的ec2实例和一个带有弹性ip的ec2实例,安全组也允许所有流量.

And then I create a ec2 instance without elastic ip and a ec2 instance with elastic ip in it, and the security group also allows all traffic.

我通过 ssh 连接到具有弹性 ip 的实例.当我运行 yum update 和 curl www.baidu.com 等时,它运行良好.但是当我 ssh 到没有弹性 ip 的 ec2 实例时,我无法访问互联网.有谁知道这是为什么?

I ssh to the instance which has elastic ip. It works well when I run yum update and curl www.baidu.com and so on. But I can't access internet when I ssh to the ec2 instance which has no elastic ip. anyone knows that is why?

推荐答案

要使用 Internet Gateway 从公有子网中的 EC2 实例访问 Internet,该实例需要具有公有 IP 地址.任一者都可以将实例配置为具有公共 IP 地址或附加 EIP.

For accessing internet from EC2 instance in public subnet using Internet Gateway, the instance needs to have public IP address. Either one can configure the instance to have public IP address or attach EIP.

参考:http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Internet_Gateway.html

如果您不想为可以访问 Internet 的实例附加公共 IP 地址(考虑私有子网),NAT 实例和 NAT 网关可以提供帮助.

If you do not want to attach public IP address for instances with Internet access (consider private subnets), NAT instance and NAT gateway can help.

参考:http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-nat.html

这篇关于ec2 实例无法在没有弹性 IP 地址的情况下访问公共子网中的 Internet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆