Guaranteeing you do not lose your IP address on AWS – inside a VPC
Public Facing Instances
If you need your AWS instance to be public facing (i.e. it hosts a public facing website etc.), you need a public IP (in addition to the private IP). A public IP address is assigned to your instance from Amazon’s pool of public IP addresses; that means it is subject to change (when you restart your instance for example).
If you require a persistent public IP address that can be assigned to and removed from instances as you require, use an Elastic IP address instead. To do this, you must allocate an Elastic IP address for use with the VPC, and then associate that Elastic IP address with a private IP address specified by the network interface attached to the instance. For more information, see Elastic IP Addresses.
Private (Internal) Facing Instances
When you launch an instance into a VPC, a primary private IP address from the address range of the subnet is assigned to the default network interface (eth0) of the instance. To ensure you DO NOT lose this IP address, you can manually ASSIGN an IP to your instance. If you don’t specify a primary private IP address, AWS selects an available IP address in the subnet range for you (but this address may change on the next restart – hence – take the time to manually assign your own private IP).
For more information about network interfaces, see Elastic Network Interfaces in the Amazon EC2 User Guide.
Leave a Reply