我有一个在AWS中运行的EC2实例。当我试图从我的本地盒子ping它是不可用的。
我如何能使实例pingable?
我有一个在AWS中运行的EC2实例。当我试图从我的本地盒子ping它是不可用的。
我如何能使实例pingable?
当前回答
检查你的安全组
2-check Internet网关
3-检查路由表
其他回答
确保使用aws ec2实例的公共IP进行ping。 编辑附加到EC2实例的安全组,并为ICMP协议添加入站规则。 尝试ping,如果这个问题没有解决,然后在安全组中添加ICMP的出站规则。
您必须编辑EC2实例所属的Security Group并允许访问(或者创建一个新的Security Group并将该实例添加到其中)。
默认情况下,一切都被拒绝。您需要添加到安全组的例外取决于您需要向internet提供的服务。
如果它是一个web服务器,你需要允许访问端口80为0.0.0.0/0(这意味着任何IP地址)。
要允许ping实例,您需要启用ICMP通信。
AWS Web控制台在相关下拉列表中提供了一些最常用的选项。
是的,您需要打开对端口的访问。查看Security Groups http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html
您的EC2实例需要附加到一个允许您所需访问的安全组。
如果你想通过SDK以编程方式启用ping(从任何地方),神奇的公式是:
cidrIp: "0.0.0.0/0"
ipProtocol: "icmp"
toPort: -1
fromPort: 8
例如,在Scala(使用AWS Java SDK v2)中,以下工作用于为authorizeSecurityGroupIngress端点定义IpPermission。
val PingPermission = {
val range = IpRange.builder().cidrIp( "0.0.0.0/0" ).build()
IpPermission.builder().ipProtocol( "icmp" ).ipRanges( range ).toPort( -1 ).fromPort( 8 ).build()
}
(我只在EC2-Classic上尝试过。我不知道在VPC下可能需要什么出口规则)
1.Go to EC2 Dashboard and click "Running Instances" on "Security Groups"
2.select the group of your instance which you need to add security.
3.click on the "Inbound" tab
4.Click "Edit" Button (It will open an popup window)
5.click "Add Rule"
6.Select the "Custom ICMP rule - IPv4" as Type
7.Enter the "0.0.0.0/0" as Source or your public IP
7.点击“保存”