Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep same IP address for EC2 Instance

Do EC2 instances change the IP address for your instance each time you stop/start the instance? Is there a way to keep the IP address constant?

like image 961
user1154644 Avatar asked Jul 27 '19 01:07

user1154644


1 Answers

Yes, there is a way: Elastic IP Addressing.

AWS instances are launched with a dynamic IP address by default, which means that the IP address changes every time the server is stopped and restarted. In many cases, this is not desired and so, users also have the option to assign the server a static IP address (also known as an “elastic IP”).3


According to Amazon 1, 2:

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.

And:

You can have one Elastic IP (EIP) address associated with a running instance at no charge. If you associate additional EIPs with that instance, you will be charged for each additional EIP associated with that instance per hour on a pro rata basis. Additional EIPs are only available in Amazon VPC.


To configure a static IP address:

  • Log in to the AWS EC2 Dashboard. If required, use the region selector in the top right corner to switch to the region where your instance was launched.
  • Select the instance in the dashboard.
  • In the left navigation bar, select the “Network & Security -> Elastic IPs” menu item.
  • Click the “Allocate New Address” button.

For more details on setting it up, see Allocating an Elastic IP Address and Configure a static IP address.

There is a charge a small hourly charge if an Elastic IP address is not associated with a running instance, or if it is associated with a stopped instance or an unattached network interface. The charge is prorated and depends on the region; details can be found on Amazon EC2 Pricing.

like image 103
AAA Avatar answered Sep 21 '22 23:09

AAA