我有一个在AWS中运行的EC2实例。当我试图从我的本地盒子ping它是不可用的。
我如何能使实例pingable?
我有一个在AWS中运行的EC2实例。当我试图从我的本地盒子ping它是不可用的。
我如何能使实例pingable?
当前回答
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.点击“保存”
其他回答
添加一个新的EC2安全组入站规则:
类型:自定义ICMP规则 协议:Echo Request 端口:N / A 来源:你的选择(我会选择任何地方,以便能够从任何机器ping)
当访问ec2实例中的新端口时。你要在两个地方相加。 1. 安全组入端口。 2. 防火墙设置入站规则。
当ping两个系统时,默认启用SSH(如果您通过putty或终端连接)。为了允许ping,我为每个实例(入站)添加了安全组。
虽然晚了几年,但希望这能帮助到其他人……
1 -首先确保EC2实例有一个公共IP。
如果有一个公共DNS或公共IP地址(下面圈出来),那么你应该是好的。这将是你ping的地址。
2 -亚马逊网络规则
接下来,确保Amazon网络规则允许Echo请求。进入EC2的安全组。
右键单击,选择入站规则 A:选择“添加规则” B:选中“自定义ICMP规则- IPv4” C:选择“Echo Request” D:选择“任何地方”或“我的IP” E:选择保存
3 -访问控制列表(如适用)
注:谢谢santosh的这一个。
您的VPC连接到一个网络,这个网络可能也有一些acl阻止它。
A: Go to the Your VPCs --> Default --> Network ACLs --> Details(Tab) --> and select the Main network ACL. (it should bring you to Network ACLs with the network id filter applied) B: Then Select the Network ACL ID (screenshot not shown) C: Under Inbound rules tab, if the current rules don't already allow ICMP, then select Edit Inbound Rule --> Add a New Rule D: Select All ICMPs - IPv4 E: Select Anywhere or type another network CIDR F: Select Allow (0.0.0.0/0 is all) G: Select Save Changes H: do the same for Outbound rules tab (if needed)
4 - Windows防火墙例外:
接下来,Windows防火墙会默认阻止入站Echo请求。通过创建windows防火墙异常允许Echo请求…
点击“开始”,输入“高级安全的Windows防火墙” 选择入站规则
完成了!
希望您现在能够ping通服务器。
如果你想通过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下可能需要什么出口规则)