我有一个在AWS中运行的EC2实例。当我试图从我的本地盒子ping它是不可用的。

我如何能使实例pingable?


当前回答

我尝试了以上步骤中的多种解决方案,但对我有效的是

更改互联网连接到我的移动热点

再试一次。我家的网络设置不允许我连接到RDP。我在哪里可以SSH到linux服务器

其他回答

如果你将规则设置为“自定义ICMP”规则和“回声回复”,它将像冠军一样工作。echo request是错误的响应ping的规则。

terrraform安全组的特定指令,因为-1对我来说不明显。

resource "aws_security_group" "Ping" {
  vpc_id = "${aws_vpc.MyVPC.id}"
  ingress {
    from_port   = -1
    to_port     = -1
    protocol    = "icmp"
    cidr_blocks = ["0.0.0.0/0"]
    ipv6_cidr_blocks = ["::/0"]
  }
}

如果您在安全组和VPC中打开,可能是您的内部网络正在阻止该IP到ping或在您的防火墙中阻止ping包。

您必须编辑EC2实例所属的Security Group并允许访问(或者创建一个新的Security Group并将该实例添加到其中)。

默认情况下,一切都被拒绝。您需要添加到安全组的例外取决于您需要向internet提供的服务。

如果它是一个web服务器,你需要允许访问端口80为0.0.0.0/0(这意味着任何IP地址)。

要允许ping实例,您需要启用ICMP通信。

AWS Web控制台在相关下拉列表中提供了一些最常用的选项。

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.点击“保存”