EC2 实例不会保留弹性 IP [英] EC2 Instances will not keep elastic IP

查看:29
本文介绍了EC2 实例不会保留弹性 IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我不明白这里发生了什么......我有 (3) 个已启动的微型 EC2 实例(没有弹性 ip)

So, I don't understand what is going on here... I have (3) Micro EC2 Instances which are launched (without elastic ip)

然后我转到 Network Security->Elastic IPs 并单击关联 IP 地址.我选择了一个正在运行的 EC2 实例,然后该实例使用弹性 ip.

I then go to Network Security->Elastic IPs and click associate IP address. I chose a running EC2 instance, that instance then uses the elastic ip.

如果我 stop, then start 这个相同的 ec2 实例,它没有与以前相同的弹性 IP 地址,而是一些全新的IP地址.这会弄乱脚本,然后这些脚本依赖于之前关联到该 EC2 实例的弹性 IP.

If I stop, then start this SAME ec2 instance, it doesnt have the same previous elastic IP address and is instead some completely new IP address. This is messing up scripts that then depend on the previously associated elastic ip to that EC2 instance.

为什么会发生这种情况,为什么我不能让 (3) 个实例采用并保留这个分配的弹性 ip?

Why is this happening and why cant i get any of the (3) instances to adopt and keep this assigned elastic ip?

推荐答案

当您停止弹性 IP 时,它们会与 EC2 实例(在 EC2-Classic 中)解除关联.您需要在启动时再次重新关联它们,这可以通过 API 完成(通过 AssociateAddress)、CLI(通过 ec2-associate-address) 或 通过 AWS 控制台.

Elastic IPs become disassociated with EC2 instances (in EC2-Classic) when you stop them. You will need to re-associate them again on startup, which can be done through the API (via AssociateAddress), CLI (via ec2-associate-address), or via the AWS Console.

这是弹性 IP 文档 不得不说:

Here's what the Elastic IP documentation has to say on the matter:

当您将 EIP 与实例关联时,实例的当前公网IP地址发布到EC2-Classic公网IP地址水池.如果您将 EIP 与实例解除关联,则实例为在几分钟内自动分配一个新的公共 IP 地址.此外,停止实例也会解除 EIP 与其的关联.

When you associate an EIP with an instance, the instance's current public IP address is released to the EC2-Classic public IP address pool. If you disassociate an EIP from the instance, the instance is automatically assigned a new public IP address within a few minutes. In addition, stopping the instance also disassociates the EIP from it.

我们通过使用所需的弹性 IP 标记我们的开发实例(夜间关闭)来解决这个问题,并在早上运行脚本以首先打开它们,然后重新关联弹性 IP.

We solve this at work by tagging our dev instances (which are turned off overnight) with the desired elastic IP and run a script in the morning to first turn them on, and then re-associate the elastic IP.

这篇关于EC2 实例不会保留弹性 IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆