I have an Amazon EC2 instance that I have been using for production and for some weird reason I did not use an Elastic IP.
Now that I want to use an Elastic IP, it seems AWS doesn't allow connection on the old IP. In my use case I need the instance to be accessible through both IPs. Is this really possible?
No. You cannot use the old public IP once you associate an elastic IP. Remember you have only one network interface, you cannot have 2 public (routable) IPs associated with it.
From Elastic IP Address Basics
If you associate an Elastic IP address with the eth0 network interface
of your instance, its current public IP address (if it had one) is
released to the EC2-VPC public IP address pool. If you disassociate
the Elastic IP address, the eth0 network interface is automatically
assigned a new public IP address within a few minutes. This doesn't
apply if you've attached a second network interface to your instance.
Related
I used "Dissociate Elastic IP address" from an Amazon EC2 instance that was running and allocated that Elastic IP address to another instance. Since doing this, the EC2 instance does not have a public IP address.
In my subnets, auto-assign Public IP address is enabled, but the EC2 instance is still not getting a public IP address. I have restarted the EC2 instance and I have Stopped it and Started it again, but there is no public IP address.
Can anyone please share with me a solution for this?
It appears that your situation is:
You removed an Elastic IP address from an Amazon EC2 instance
The instance was not automatically assigned a Public IP address even though "Auto-Assign Public IP" is enabled on the subnet
It sounds like the Amazon EC2 instance was launched with "Auto-Assign Public IP" turned OFF.
From Amazon EC2 instance IP addressing - Amazon Elastic Compute Cloud:
The public IP addressing feature is only available during launch. However, whether you assign a public IP address to your instance during launch or not, you can associate an Elastic IP address with your instance after it's launched.
Since the instance was launched with this feature turned OFF, a Public IP address will not be assigned to the instance when the Elastic IP address is removed.
To provide the instance with a Public IP address, you will need to create another Elastic IP address and assign it to the instance.
I have a scenario where I want to setup an haproxy cluster with keepalived. I saw this blog post https://www.peternijssen.nl/high-availability-haproxy-keepalived-aws/ and its pretty detailed and easy to follow, but for my scenario I need the elastic IP's to be private. Is this doable ? As from AWS documentation Elastic IP's are only public IPs.
I need a floating IP which will act as a floating cluster IP. What can I use if Elastic IP is not an option.
An elastic IP within AWS is actually a static public IP address. This functionality is required as by default a public IP address is not reserved by an account, and when enabled limits the total IPv4 addresses you can keep.
For private address ranges however, your instances can be assigned any private IP address that is within any of your VPCs CIDR range(s).
In fact for this reason you can select almost any IP address found within your VPC when launching a new instance, in addition the IP addresses that are attached to an EC2 instance are static and will be attached to that instance until it is terminated.
Therefore as long as you don't terminate the instances the private IP(s) will be maintained. However, in the event the instance fails and is not recoverable you would still need to launch a new instance and use that IP.
It might be more beneficial using a DNS record to resolve the IP just in case of an emergency, or failing that use a load balancer to distribute traffic.
For this case you can provision an Elastic Network Interface (ENI) with a static private IP address which you can attach/re-attach to EC2 instances. As long as you don’t delete the ENI, it will retain the I as p address. Find out more here: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html
I'm using an AWS EC2 window's instance which has an Public IP. The Public IP is not elastic. The instance runs some app.
Now I've to deploy the app in ubuntu but the Public IP must be preserved. How can I do this?
When I allocate New Elastic IP, I get a random IP address, but I need the existing one which is being used by window's instance.
Is there any way to allocate existing Public IP to elastic IP?
No you will not be able to do that. You cannot convert an AWS Public IP to an Elastic IP. Once you close the server the public IP address gets released. You will have to make the necessary changes to your app to use the new IP address for the ubuntu and this time make sure you use elastic IP for the instance.
I'm a new user of AWS/EC2. I'm not sure that how Amazon manage a pair of EIP and ENI.
What I want to do in ec2 is to use a software license which is related to MAC address. So for using this license, I have to keep a same MAC address on EC2.
Actually I've already prepared my EIP, and it looks this EIP is related to specific ENI. So I think that the pair of this EIP and ENI is keeped unless I release this EIP or ENI. Is my understanding right?
No, EIP (Elastic IP address) can be assigned to any ENI on that instance, and it can be released and assigned to another ec2 instance or ENI as well.
For Elastic Network Interfaces (ENI), the best explanation is from AWS:
An elastic network interface (ENI) is a virtual network interface that you can attach to an instance in a VPC. An ENI can include the following attributes:
A primary private IP address.
One or more secondary private IP addresses.
One Elastic IP address per private IP address.
One public IP address, which can be auto-assigned to the elastic network interface for eth0 when you launch an instance, but only when you create an elastic network interface for eth0 instead of using an existing network interface.
One or more security groups.
A MAC address.
A source/destination check flag.
A description.
Refer:
Elastic Network Interfaces (ENI)
I have a server that is up and running with an auto-assigned public IP address. This IP address was not created with Elastic IP. Is there anyway to transfer this IP address onto a new instance in my account?
I'm afraid you can't.
The auto assigned public IPs are not yours to deassociate and reassociate.
You can't tell them "I changed my mind, I want to use this IP as if it was an Elastic IP". It doesn't work like that. You can't really pick your elastic IP. You just ask for one, and then operate with whatever IP they gave you.
You cannot manually associate or disassociate a non-elastic IP address from your instance. Instead, in certain cases, aws release the public IP address from your instance, or assign it a new one for below cases:
1. They release the public IP address for your instance when it's stopped or terminated. Your stopped instance receives a new public IP address when it's restarted.
They release the public IP address for your instance when you associate an Elastic IP address (EIP) with your instance, or when you associate an EIP with the primary network interface (eth0) of your instance in a VPC. When you disassociate the EIP from your instance, it receives a new public IP address.
If the public IP address of your instance in a VPC has been released, it will not receive a new one if there is more than one network interface attached to your instance.
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html#concepts-public-addresses
If you require a persistent public IP address that can be associated to and from instances as you require, use an Elastic IP address (EIP) instead. You can allocate your own EIP, and associate it to your instance. For more information, please see Elastic IP Addresses (EIP).
Easy, setup a HTTP or TCP transparant proxy, with HAProxy or Nginx.