Access Amazon EC2 VPC Instance with Multiple IP Addresses - amazon-ec2

We have created a new EC2 VPC instance on Amazon.
When we created instance at Amazon, it was created with IP address generally know as a Public IP.
For ex: Public IP: xx.xxx.xxx.xx
And we can access our site using above public IP Address (xx.xxx.xxx.xx).
Now we need to create one another public IP address for our site.
For ex: Public IP: yy.yyy.yyy.yy
Is it possible to create multiple IP addresses? If yes, then how to do that? Let us inform with an appropriate answer.
Note that after assigning multiple addresses, our site should be accessed on any of the IP addresses assigned.

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html
Multiple IP
EC2-Classic:
Instances support only a single private IP address and a corresponding EIP.
EC2-VPC:
Instances support multiple IP addresses, and each one can have a corresponding EIP. For more information, see Multiple Private IP Addresses http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/MultipleIP.html

You can not assign multiple (free of charge) public IP addresses to a single instance.
But you could assign an additional network interface at your instance and configure your system to work with two interfaces. After that you can assign an Elastic IP to your new interface (extra costs).

Related

How do I look up the IP address range used by my AWS load balancer for creating instances?

My API accesses a service that wants to know what the possible IP address range is for the API so they can whitelist us. How do I know what IP addresses AWS may assign when the load balancer creates new instances?
Direct answer: AWS publishes its IP address ranges in a publicly accessible JSON file. IP ranges are associated with a region and a service, and as you can imagine, there are a lot of them. At the current moment there are 71 CIDR blocks associated with EC2 in us-west-2, for example. That's as specific as you can get, though. So you'd have to supply your partner with all of the EC2 IP address ranges for your region in order to guarantee that they would permit any IP address assigned to an instance your autoscale group might start up. Oh, and they do change periodically, so your partner would have to maintain that list.
Suggestion: Sounds like you have your EC2 instances in public subnets and are assigning public IPs to them. Instead, you can create your EC2 instances in private subnets and use a NAT Gateway to allow them to access the Internet. If you do this, the source IP for outbound traffic will the be the elastic IP address you assign to the NAT gateway. So you can give your partner a definite IP address they can permit to access their service.
Using a private subnet for your EC2 instances also reduces your attack surface area, since the EC2 instances won't have individual public IP addresses.

How to put public IP address directly on EC2 Instance network card

When I create a machine on Amazon AWS it always comes with Public and Private IP.
I need to have the public IP directly on the server's network card.
It's possible?
I don't think this is possible. What AWS does, is a mapping from public IP address to the primary private IP address using network address translation (NAT). They actually don't assign a public IP address to EC2 instances.
More info AWS Doc

AWS Elastic IPs instead of Public IPs?

Why doesn't AWS allocate elastic IP's to all the servers being spawned? They allocate public IP by default to all the servers, which gets lost after a reboot of EC2 instances.
What's the logic behind not allowing elastic IPs automatically?
TL;DR Because Elastic IP (EIP) addresses are not needed for all/most use cases.
There is a limited supply of routable IP addresses. If every server on a public subnet received one, those IP addresses would remain allocated even when the servers were off. If the server was terminated it would be unclear if the use of that IP was concluded or is still necessary for other use. Which brings up the real reason for Elastic IP's.
An Elastic IP address is a static IPv4 address designed for dynamic cloud computing. An Elastic IP address is associated with your AWS account. With an Elastic IP address, you can mask the failure of an instance or software by rapidly remapping the address to another instance in your account. [1]
The take away from this is if you're not using EIP's for dynamic cloud computing you're probably using them incorrectly. This is a good example of a correct use case.
If you require a persistent public IP address that can be associated to and from instances as you require, use an Elastic IP address instead. For example, if you use dynamic DNS to map an existing DNS name to a new instance's public IP address, it might take up to 24 hours for the IP address to propagate through the Internet. As a result, new instances might not receive traffic while terminated instances continue to receive requests.[2]

Change public IP address of EC2 instance to Elastic IP Address

Is it possible to assign Elastic IP Address to my instance without changing the public IP address?, i need to Transforms my public IP address to be Elastic IP Address
Yes. It is possible. You can access your instance with Both Elastic IP as well as Public IP Address. But remember when your EC2 instance restart at that time its public IP may get change so people preferring to use Elastic IP Address.
Hope this Helps !
Using Elastic Network Interfaces it is possible if you started the instance in a VPC. You can assign the Elastic IP to an Elastic Network Interface which you can then attach to the EC2 instance. EC2 instances in VPC can have multiple ENI. If you assign an EIP directly to the EC2 instance (classic or VPC) then the public IP changes to the 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.
from: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html

How does EC2‘s public ip works?

When I launch an EC2 instance,I will get a private ip and public ip.The public ip can be
visited by a dns domain like 'ec2-184-73-237-10.compute-1.amazonaws.com'.When I ping it,I got ip address 184.73.237.10.
My question is: does 184.73.237.10 only belongs to me or it's shared by different instances?
If it's shared by different instances,how does it work? As far as I know, each instances(linux) can be accessed by ssh.
Thanks in advance :-)
It only belongs to you (there is a 1:1 mapping between public and private IP addresses), but it can change at any time. For this reason, if you need an instance to be permanently accessible by IP they recommend using an Elastic IP Address. EIP is free as long as it's actually associated with an instance.
It is recommended to create and associate an Elastic IP (AWS's static IP) to your instance. And this IP will be only yours.
The benefit of Elastic IP, is that, even you can associate it to other instance, restored server from the AMI image of parent instance, thus bring back your site in case of any issues/attacks.

Resources