如何在相同子网范围的ec2实例中分配/生成新IP地址? [英] How to allocate/generate new IP address in ec2 instance in same subnet range?

查看:161
本文介绍了如何在相同子网范围的ec2实例中分配/生成新IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以通过转到弹性IP->分配新地址来获取新IP地址,但是这样做总是可以得到不同子网范围内的IP。

I know I can get new IP address by going to Elastic IPs --> Allocate new address but by doing this I always get IPs in different subnet range.

我要使用相同子网的IP。

I want to IPs with same subnet.

我有两个ec2实例,实际上我想要一个在相同子网范围内的2个新IP地址!我试图加入位于同一ZONE和同一VPC中的两个实例,但是它们的主要私有IP在不同的子网中,所以这就是问题!

I have two ec2 instance, Actually I want a 2 new IP address with in same subnet range! Am trying to join two instances which is in same ZONE and same VPC, but their primary private IPs are in different subnet, so this is the issue!

我添加了一个次要私有IP直接到两个具有相同子网范围的实例(通过不使用弹性IP,然后将它们关联),那么有什么办法可以使这个次要私有IP作为我的主要IP?

I Have added a secondary Private IP directly to both instances with same subnet range ( by not using Elastic IP and then associating them) , So is there a way I can make this secondary Private IP as my primary one?

推荐答案

我找到了解决我问题的方法:

I Found a solution for my problem:

在创建新实例本身的同时,我们可以在相同的子网范围。

While creating new instance itself we can assign IP address within the same subnet range.

以下是步骤:
首先准备好

Here are the steps : First have this ready


  • 转到VPC->创建子网

  • 转到网络与安全->创建网络接口

然后,
*启动实例->选择AMI->选择实例类型->配置实例

Then, * Launch Instance --> Choose the AMI --> choose instance type --> configure instance

在配置实例下:

*选择您刚刚创建的网络和子网

*Select the network and subnet you have just created


  • 自动分配公共IP:启用

然后在同一页上,您会看到网络接口的缺点:$ b​​ $ b在这里,添加主IP,辅助Ip(您可以根据订阅添加任意数量)

Then in same Page , downside you see Network interfaces : Here , Add Primary Ip , secondary Ip (you can add as many based on your subscription)

但是对于免费的最多2层,您可以添加!!

But for a free tier max 2 you can add !!

但是最主要的是,您可以从创建的子网范围中分配所需的任何IP。

But main thing is you can assign any IP you need from that subnet range you had created.

希望这对某人有帮助。

这篇关于如何在相同子网范围的ec2实例中分配/生成新IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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