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

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

问题描述

我在做aws。我创建了一个公共子网,该子网具有允许所有网络流量的网络ACL,并与路由表中的Internet网关关联。

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.

然后,我创建了一个没有弹性的ec2实例ip和其中包含弹性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并卷曲www.baidu.com等时,它运行良好。但是,当我SSH到没有弹性IP的ec2实例时,我无法访问Internet。有人知道这是为什么吗?

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

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

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