How to allocate/generate new IP address in ec2 instance in same subnet range?

你离开我真会死。 提交于 2019-12-19 13:36:08

问题


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.

I want to IPs with same subnet.

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!

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?


回答1:


Based on the documentation it isn't possible to select the IP from an address range for Elastic IP's unless you own the IP address space.

You can allocate an Elastic IP address from Amazon's pool of public IPv4 addresses, or from a custom IP address pool that you have brought to your AWS account. For more information about bringing your own IP address range to your AWS account, see Bring Your Own IP Addresses (BYOIP).

You may be able to hack around this but I don't think AWS would look kindly upon it.




回答2:


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

  • goto VPC --> Create Subnet
  • goto network&security --> create networkinterface

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

Under configure instance :

*Select the network and subnet you have just created

  • Auto-assign Public IP : Enable

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

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

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

Hoping this will help someone.



来源:https://stackoverflow.com/questions/54906244/how-to-allocate-generate-new-ip-address-in-ec2-instance-in-same-subnet-range

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!