AWS introduced new public IPv4 pricing in 2024:
- $0.005 per hour per public IPv4 = $3.60/month each
- Applies whether the IP is Elastic or directly attached to an EC2.
- This cost is in addition to your EC2, VPC, and data transfer charges.
If you run multiple domains or services on AWS, these charges add up quickly. Below is a step-by-step cost reduction playbook.
๐น 1. Consolidate Domains on Fewer Public IPs
- Instead of assigning 1 IP per domain, you can serve multiple domains from a single IP using Virtual Hosts in Apache/Nginx.
Example: Apache VirtualHosts
<VirtualHost *:80>
ServerName domain1.com
DocumentRoot /var/www/domain1
</VirtualHost>
<VirtualHost *:80>
ServerName domain2.com
DocumentRoot /var/www/domain2
</VirtualHost>
<VirtualHost *:80>
ServerName domain3.com
DocumentRoot /var/www/domain3
</VirtualHost>
- Point all DNS records (
A
orCNAME
) to the same EC2 public IP. - The web server selects the right site based on the
Host
header. - Savings: 3 IPs โ 1 IP = cut IPv4 cost by 66% (from $11.16 to $3.72/month).
๐น 2. Use Application Load Balancer (ALB)
- ALB provides a single DNS name (e.g.,
myapp-1234567890.ap-south-1.elb.amazonaws.com
). - Supports host-based routing:
domain1.com โ target group 1
domain2.com โ target group 2
- You donโt need any public IPs on EC2 (only private IPs in private subnets).
- ALB has a fixed hourly + LCU cost (~$16โ$18/month), so itโs cost-effective if:
- You manage 5+ domains.
- You want SSL offloading, WAF, auto-scaling.
๐น 3. Put Domains Behind CloudFront CDN
- CloudFront distributions donโt charge per IP.
- Each distribution gets a public edge DNS name (e.g.,
dxxxxx.cloudfront.net
). - Attach your custom domains via CNAME + ACM certificate.
- CloudFront forwards traffic to your EC2 instanceโs private IP or ALB.
- You can consolidate dozens of domains behind CloudFront, all with zero IPv4 cost.
๐น 4. Embrace IPv6 (Free)
- AWS charges for IPv4, but IPv6 is free.
- Steps:
- Enable dual-stack networking for EC2/ALB/CloudFront.
- Add AAAA DNS records for your domains.
- Encourage users/CDNs/ISPs to connect via IPv6.
- Youโll still need at least 1 IPv4 for compatibility, but gradually traffic shifts away.
๐น 5. Release Idle Elastic IPs
- Check for unused Elastic IPs:
aws ec2 describe-addresses --query "Addresses[?AssociationId==null]"
- Release them:
aws ec2 release-address --allocation-id eipalloc-xxxxxx
- AWS charges for unattached Elastic IPs, so donโt keep them reserved if not in use.
๐น 6. Use DNS Instead of IPs for Apps
- Many setups bind services directly to public IPs.
- Instead, use Route 53 (or any DNS provider) and map domain โ single public endpoint.
- This avoids the โ1 IP per serviceโ trap.
๐น 7. Automate Audit & Alerts
- Enable AWS Cost Explorer + Budgets:
- Track IPv4 cost (
Amazon Virtual Private Cloud โ Public IPv4 Address
line item). - Set alerts if IPv4 spend > $5โ$10.
- Track IPv4 cost (
- Run a weekly script to list public IP usage:
aws ec2 describe-instances --query "Reservations[*].Instances[*].[InstanceId,PublicIpAddress]" --output table
โ Summary of Optimization Options
Strategy | Effort | Savings | Best For |
---|---|---|---|
VirtualHosts (1 IP, many domains) | Easy | High (66โ80%) | Small setups, 2โ10 domains |
Release unused IPs | Easy | Small (~$3.60/IP/mo) | Anyone with idle Elastic IPs |
ALB (DNS-based routing) | Medium | Moderate | Multi-domain, need SSL/WAF/scaling |
CloudFront (CDN) | Medium | High (remove all IPv4 costs, reduce egress too) | Global traffic, static assets |
IPv6 adoption | Medium/Long | Future-proof | Long-term savings, modern apps |
๐ Recommended Path (for your case)
Since you said 3 domains โ 3 EC2 public IPs:
- โ Switch all 3 domains to 1 EC2 public IP (via Apache VirtualHosts).
- โ Release the 2 extra Elastic IPs.
- Later, move everything behind CloudFront โ $0 IPv4 charge + huge egress savings.
- Enable IPv6 dual-stack now to future-proof.
๐ This way your IPv4 cost drops from $11.16 โ $3.72 now, and eventually $0.