Amazon Elastic Compute Cloud (EC2)

Basics of EC2

EC2 static and dynamic IP address

In this guide, you’ll learn how Amazon EC2 instances obtain public IP addresses—both dynamic and static—and when to choose each option for your workloads.

Real-World Analogies

To understand EC2 public IP behavior, consider these everyday scenarios:

  1. Static allocation (phone number):
    When you purchase a SIM card, your mobile provider assigns you a permanent phone number. People can reach you consistently using that number.

  2. Dynamic allocation (hotel room):
    At a hotel, you get a room for the duration of your stay. Once you check out, the room returns to the pool and may be reassigned to someone else next time.

These maps neatly to AWS EC2’s public IP models:

  • Static ⇨ Elastic IP
  • Dynamic ⇨ Auto-assigned public IPv4 address

Dynamic Public IP Addresses

The image illustrates the structure of an AWS cloud setup, showing a region with an AWS account containing both a default and a custom VPC, each with their own public subnets, and a pool of public IPs.

How Dynamic Public IPs Work

  • Default VPC: EC2 instances launched in the default VPC receive a public IPv4 automatically.
  • Custom VPC: Public IP assignment is disabled by default. Enable Auto-assign public IPv4 address on the subnet to grant instances a public IP on launch.

Lifecycle and Limitations

The image illustrates the concept of EC2 dynamic IP addresses within an AWS cloud environment, showing the relationship between AWS accounts, VPCs, and public subnets. It also notes that IPs are released back to the pool when instances are stopped, hibernated, or terminated.

  • When an instance is stopped, hibernated, or terminated, its public IPv4 address is released back to AWS’s global pool.
  • Restarting a stopped instance assigns a new public IP.
  • You cannot manually associate or disassociate an auto-assigned public IP.
  • Frequent IP changes can disrupt services with static DNS records.

Note

Dynamic DNS services may take up to 24 hours to propagate a new IP, risking temporary downtime. For production-grade stability, consider Elastic IPs.

Learn more in the AWS EC2 addressing guide.


Elastic IP Addresses (Static)

Elastic IPs are AWS’s solution for static, publicly routable IPv4 addresses—like owning a permanent phone number.

The image is a diagram illustrating the concept of an EC2 Elastic IP Address within AWS Cloud, showing two regions (ap-southeast-1 and us-east-1) each containing an AWS Account.

Key Characteristics

  1. Region-bound: You allocate an Elastic IP within a single AWS Region.
  2. Account-level allocation: Once allocated, the address resides in your AWS account until you release it.
  3. Association: Attaching to an EC2 instance binds the IP to eth0 (the primary network interface).
  4. Reassignment: Disassociate and reattach to any eligible instance or network interface in the same region.
  5. Pricing:
    • Free when attached to a running instance.
    • Hourly charge when allocated but not associated.

Warning

Unused Elastic IPs incur charges. Always release any Elastic IP you no longer need to avoid unexpected costs.

For full details, see Elastic IP address documentation.


Comparing Static vs. Dynamic Public IPs

Below is a quick reference table summarizing the core differences between dynamic (auto-assigned) and static (Elastic) public IP addresses in EC2.

AttributeDynamic Public IPElastic IP (Static)
AssignmentAuto-assigned on launchAllocated to your AWS account
LifetimeExists only while instance is runningPersists until you release it
Manual ManagementNot supportedYou can associate/disassociate at will
DNS StabilityIP changes on stop/startFixed IP, no DNS propagation issues
CostFree while attachedFree when attached; charged when idle

The image is a comparison table summarizing the differences between EC2 Static and Dynamic IP addresses, highlighting attributes such as region specificity, account assignment, and reallocation capabilities.


Further Reading and References

Watch Video

Watch video content

Practice Lab

Practice lab

Previous
Demo Access EC2 Instance web console SSH Key