一个和我一起工作的人给了我登录到他的EC2控制台的EC2凭证。不是我设的局。一些实例显示公共dns名称,而其他实例则显示空白的公共dns。我希望能够连接到具有空白公共DNS的实例。我一直无法弄清楚为什么这些显示为空白。


当前回答

您不必为实例分配公共ip地址。 可以使用NAT实例,也可以使用NAT网关。

https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Scenario2.html https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-comparison.html

其他回答

这与VPC的“DNS主机名”特性有关。您可以启用或禁用它。进入VPC,在“操作”菜单中选择“编辑DNS主机名”,然后选择“是”。这样做之后,应该会显示EC2实例的公共DNS。

进入VPC控制台,选择您的VPC,单击“操作”菜单,选择“编辑DNS主机名”—选择“是”。这应该能解决问题。

实际上,在VPC中有一个叫做“DNS主机名”的设置。可修改EC2实例所在的VPC,将该选项修改为“是”。这样应该可以了。

我昨天遇到了这个问题,尝试了曼尼的上述答案,但没有奏效。不过,VPC的设置对我很有用。

最终我添加了一个EIP,我用它来连接。

在这里,我将总结最常见的问题:

When you create a custom VPC, if you want aws resources such as ec2 instances to acquire public IP addresses so that the internet can communicate with them, then you first must ensure that the ec2 instance is associated with a public subnet of the custom VPC. This means that subnet has an internet gateway associated with it. Also, you need to ensure that the security group of the VPC associated with ec2 instance has rules allowing inbound traffic to the desired ports, such as ssh, http and https. BUT here are some common oversights that still occur:

1)确保VPC已启用DNS主机名

2)您必须确保连接到EC2实例的公共子网启用了“自动分配公共ip”标志

3)如果实例已经创建,那么您可能需要终止它,并为要填充的公共IP和公共DNS字段创建一个新实例。

在我的情况下,我从《被路西法杀死》和其他指向同样的答案中找到了答案。 即使设置了DNS主机名:是的,my-pvc上没有分配公共IP(只有私有IP)。

“自动分配公共IP”必须设置为“启用”。 如果未选中,则默认设置为“使用子网设置(禁用)”