Assign Public IP (not Elastic IP) after instance launched

Solution 1:

The instance that you launched without a public IP will stay without one as it is only assignable when you launch the instance. Even having a subnet with auto assign public IP switched on will not assign a public IP to your instance if, when you launched the instance you chose not to have a public IP.

The only way I know is to select assign a public IP before launching the instance or having the subnet set up to auto assign public IPs which will do that only when you launch a new instance.

So to summarize: It is not possible to assign a public IP after launching that instance unless you use EIPs.

Solution 2:

To correct it afterwards, spin down your original server, spin up a new with auto assign public IP enabled and the existing volumes attached.

You can then discard the original instance.

Solution 3:

If you are using ELB and Autoscaling, creating instance on fly and to stress test the instance is difficult. One solution during this scenario:

Select EC2 instance> Actions>Networking> Manage Ip Addresses. Then use option "To add or edit an IPv4 public IP Allocate an Elastic IP to this instance or network interface".

  1. Create an elastic IP
  2. Navigate to Elastic IP address link> click Associate IP
  3. Select the instance to associate IP and save.

Now you will have EC2 instance with public IP without restarting/deleting EC2 instance.

Solution 4:

Assuming your instance is running in a VPC you can create an Elastic Network Interfaces (ENI) that has a public IP assigned to it then associate that ENI with your instance without needs to create a new one.


Amazon Ec2