You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
EC2 networking goes beyond basic IP assignment. Elastic IP addresses provide stable public endpoints, and Elastic Network Interfaces (ENIs) give you fine-grained control over how instances connect to the network. This lesson covers both, along with practical scenarios and best practices.
An Elastic IP is a static, public IPv4 address that you allocate to your AWS account and can associate with any EC2 instance or network interface in the same Region.
Unlike auto-assigned public IPs (which change every time you stop and start an instance), an Elastic IP remains the same until you explicitly release it.
| Scenario | Without EIP | With EIP |
|---|---|---|
| Instance restart | Public IP changes; DNS records become stale | Public IP stays the same |
| Instance failure | Must update all references to the new IP | Remap EIP to a replacement instance in seconds |
| Multi-homed instances | Limited to one public IP | Assign multiple EIPs to different ENIs |
# Allocate an Elastic IP
aws ec2 allocate-address --domain vpc
# Returns: AllocationId = eipalloc-0abcdef1234567890, PublicIp = 203.0.113.25
# Associate with an instance
aws ec2 associate-address \
--allocation-id eipalloc-0abcdef1234567890 \
--instance-id i-0123456789abcdef0
# Disassociate from an instance
aws ec2 disassociate-address \
--association-id eipassoc-0abcdef1234567890
# Release the EIP back to the pool
aws ec2 release-address \
--allocation-id eipalloc-0abcdef1234567890
| Condition | Cost |
|---|---|
| EIP associated with a running instance | Free (first EIP per instance) |
| Additional EIPs on same instance | Charged per hour |
| EIP not associated with any instance | Charged per hour (idle EIP) |
| EIP on a stopped instance | Charged per hour |
| Data transfer through EIP | Standard data transfer rates |
Important: AWS charges for idle Elastic IPs to discourage hoarding of scarce IPv4 addresses. Always release EIPs you are not using.
By default, each AWS account is limited to 5 Elastic IPs per Region. You can request an increase through the Service Quotas console, but AWS encourages alternatives:
An Elastic Network Interface is a virtual network card that you attach to an EC2 instance. Every instance has at least one ENI (the primary ENI, eth0), and you can attach additional ENIs for advanced networking scenarios.
Each ENI carries several network attributes:
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.