AWS IP Addresses: Private, Public, and Elastic IPs Explained
Amazon Web Services (AWS) provides robust networking capabilities, and understanding IP address types—Private, Public, and Elastic IPs—is crucial for managing resources in the cloud.
Whether you're launching an EC2 instance or configuring a Virtual Private Cloud (VPC), knowing how these IPs work will help you.
Let's breaks down each type, their use cases, and practical steps to implement them.
Private IP:
The Backbone of Internal Communication, A Private IP is a fixed, non-routable IP address assigned to an EC2 instance within a Virtual Private Cloud (VPC). It’s used for secure internal communication between resources, such as EC2 instances, databases, or load balancers, within the same VPC or across peered VPCs.
Private IPs are drawn from the RFC 1918 address ranges (e.g., 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) and are automatically assigned when you launch an instance.
For example, an EC2 instance might get a Private IP like 172.31.7.164. This IP remains unchanged even if the instance is stopped or restarted, ensuring consistent internal addressing. Think of it as the instance’s permanent address within your private network, inaccessible from the public internet.
Use Case: A web server communicating with a database server in the same VPC uses Private IPs to securely exchange data without external exposure.
Example: A web server communicating with a database server in the same VPC uses Private IPs to securely exchange data without external exposure.
Public IP:
Connecting to the Outside World ,a Public IP is a dynamic, routable IP address assigned to an EC2 instance to enable communication with the public internet.
When you launch an instance in a public subnet with “Auto-assign Public IP” enabled, AWS allocates a Public IP (e.g., 3.109.213.248).
However, this IP is ephemeral—stopping and restarting the instance releases the Public IP, and a new one (e.g., 13.235.79.233) is assigned.
This dynamic nature can disrupt applications requiring a consistent public address, such as hosting a website or connecting via SSH from a fixed client
Example: A developer SSH-ing into an EC2 instance from their local machine uses the Public IP to establish the connection.
EC2 console with Public IP and Private IP
EC2 console with Public IP and Private IP after stopping Instance, Public IP gets removed.
EC2 console after restarting an instance the IP changes and new IP is assigned but Private IP remains same.
Elastic IP:
Fixed Public Addressing, an Elastic IP is a static, public IP address that you can allocate from AWS's pool and associate with an EC2 instance.
Unlike a dynamic Public IP, an Elastic IP (e.g. 65.0.78.209) remains constant even after instance restarts, making it ideal for applications requiring a fixed public address, like web servers or APIs.
Caution: Elastic IPs are a paid service. AWS charges for Elastic IPs that are allocated but not associated with a running instance. For learning purposes, always release unused Elastic IPs to avoid unexpected costs.
Practical Steps to Use Elastic IP:
Allocate: In the EC2 console, navigate to “Elastic IPs” under the “Network & Security” section. Click “Allocate Elastic IP address” to get an IP (e.g., 65.0.78.209).
Associate: Select the Elastic IP, click “Actions” and choose “Associate Elastic IP address.” Select your EC2 instance to link it.
Test: Restart the instance and verify the Public IP remains unchanged (e.g., 65.0.78.209).
Disassociate: To free the Elastic IP, select it, click “Actions,” and choose “Disassociate Elastic IP address.”
Release: Return the IP to AWS by selecting “Release Elastic IP address” to avoid charges.
Key Rule: An Elastic IP can only be associated with one EC2 instance at a time. To use it with another instance, you must first disassociate it from the current one.
Allocating Elastic IP
Associating Elastic IP with Instance
After stopping Instance Elastic IPs does not gets removed.
After restarting Instance the elastic public IP remains Unchanged
Conclusion
Understanding AWS’s Private, Public, and Elastic IPs empowers you to design robust, scalable, and cost-efficient architectures. Private IPs secure internal communication, Public IPs enable external access, and Elastic IPs provide static public addressing for production needs. By following the practical steps and leveraging screenshots, you can confidently manage IPs in your AWS environment. For hands-on learning, experiment in the AWS Free Tier, but always release unused Elastic IPs to avoid charges.