Public Vs Private Vs Elastic IP
Public IP:
- Public IP means the machine can be identified on the internet (www)
- No two machine will have same IP address.
- Every EC2 instance has a public IP.
- If you stop and then start the EC2 instance the public IP is changed.
Private IP:
- Private IP means the machine can be identified on a private network only.
- Two machines from 2 different private network can have same IP address, but not in a same private network.
- Machines connect to Internet(www) using NAT + Internet Gateway.
- Every EC2 instance has a private IP.
- When you are doing SSH to your EC2 instance you can’t use the private IP since you are not in the same network. You can use the public IP for the same purpose.
Elastic IP:
- When you stop and start an EC2 instance, its public IP is changed.
- But if you want a fixed public IP, you need something called Elastic IP.
- Unless you delete a Elastic IP, you own it permanently.
- Elastic IP should be avoided because its a poor architectural decisions.
- Alternatively, you can use a Load Balancer and don’t use a public IP