如何排查 EC2 实例上的弹性 IP 地址问题?

2 分钟阅读
0

我在分配或释放与 Amazon Elastic Compute Cloud (Amazon EC2) 实例关联的弹性 IP 地址时出现错误。或者,我需要恢复意外删除的弹性 IP 地址。如何排查弹性 IP 地址的常见问题?

简短描述

以下是 AWS 账户中的弹性 IP 地址可能出现的常见问题:

  • 我想恢复意外删除的弹性 IP 地址。
  • 即使在终止 EC2 实例之后,也不会释放关联的弹性 IP 地址。
  • 尽管弹性 IP 地址与我的任何资源都没有关联,但我还是被收取费用。
  • 分配新的弹性 IP 地址时,出现错误: "Elastic IP address could not be allocated.The maximum number of addresses has been reached."
  • 将弹性 IP 地址关联到我的一个 EC2 实例时,出现错误: "Elastic IP address could not be associated.You are not authorized to perform this operation."
  • 从我的账户中释放弹性 IP 地址时,出现错误: "Elastic IP address could not be released.You do not have permission to access the specified resource."

解决方法

我想恢复意外删除的弹性 IP 地址

如果释放了弹性 IP 地址,也许能将其恢复。有关更多信息,请参阅恢复弹性 IP 地址

即使在终止 EC2 实例之后,也不会释放关联的弹性 IP 地址

要释放弹性 IP 地址,必须先将其与所有资源断开关联。有关更多信息,请参阅取消关联弹性 IP 地址

取消关联弹性 IP 地址后,可以将其与其他资源重新关联。分配给 VPC 使用但未与实例关联的任何弹性 IP 地址都需要付费。如果不需要弹性 IP 地址,则可以将其释放。有关更多信息,请参阅释放弹性 IP 地址

分配新的弹性 IP 地址时,我收到错误:"Elastic IP address could not be allocated.The maximum number of addresses has been reached"

所有 AWS 账户的每个区域限制使用五个弹性 IP 地址。如果您收到**“已达到最大地址数”**错误,请验证正在使用的弹性 IP 地址数量以及账户的限制数量

如果需要额外的弹性 IP 地址,请申请增加配额。创建配额增加请求时,请在 AWS 服务选项卡上搜索 EC2-VPC Elastic IPs

将弹性 IP 地址关联到我的一个 EC2 实例时,出现错误: "Elastic IP address could not be associated.You are not authorized to perform this operation"

AllocateAddress API 调用用于为 AWS 账户分配弹性 IP 地址。AssociateAddress API 调用用于将弹性 IP 地址与您的资源相关联。

确保使用该命令的 AWS Identity and Access Management (IAM) 用户或角色在所附的 IAM 策略中拥有以下所需权限:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "ec2:AllocateAddress",
                "ec2:AssociateAddress"
            ],
            "Resource": "*"
        }
    ]
}

从我的账户中释放弹性 IP 地址时,出现错误: "Elastic IP address could not be released.You do not have permission to access the specified resource."

当您尝试释放或取消关联 AWS 托管服务使用的弹性 IP 地址时,会出现此错误消息。AWS 托管服务的示例包括弹性负载均衡 (ELB)、NAT 网关、Amazon Elastic File System (Amazon EFS) 等。要释放与 AWS 托管服务关联的弹性 IP 地址,请删除使用该地址的资源。例如,如果您有一个 NAT 网关附加了弹性 IP 地址,则必须先删除 NAT 网关,然后才能释放弹性 IP 地址。


相关信息

弹性 IP 地址

AWS 官方
AWS 官方已更新 4 年前