Learn what is elastic IP and public IP means in AWS. List out all differences between elastic IP and public IP in AWS.
I was having conversation about AWS with one of my friend and he came up with question what is difference between elastic IP and public IP? So, I explained him and though why not draft an post about it! So in this article we will see difference between elastic IP and public IP in AWS. This can be cloud interview question so without much delay lets get into elastic IP vs public IP battle.
What is elastic IP in AWS?
First thing first, lets get basics clear. What is elastic IP? It is IPv4 IP address designed and exist for dynamic cloud computing and reachable over internet. By name you can imagine its a flexible IP which can be used or mapped rapidly from one EC2 instance to another when currently associated instance fails. This way end user or application continue to talk to same IP even if instance behind it fails. They are like static public IPs allocated for your AWS account.
What is Public IP in AWS?
Public IP is IPv4 IP address which is reachable over internet. Remember switching flexibility of Elastic IP is not available for this IP. Amazon also assigns external/Public DNS name (shown in screenshot) to instances who receives public IP. Public IP of instance is mapped to primary private IP of that instance via NAT (Network Address Translation) by default.
Refer below screenshot from EC2 console of AWS and observe where you can check your elastic IP, public IP and public DNS name.
Difference between elastic IP and Public IP
Now lets look at difference between these two IP types.
- Whenever new EC2 instance spin up, its assigned with public IP by default. Elastic IP is not assigned by default.
- Elastic IPs are assigned to AWS accounts which you can attach to instances. Public IPs assigned to instances directly.
- When instance is stopped and started again, public IP gets changed. But if instance is assigned with elastic IP, it will remain the same even if instance is stopped and started again.
- If elastic IP is allocated to your account and not in use then you will be charged for it on hourly basis.
- Public IP released once your instance is stopped so no question of getting charged for not using it.
- You wont be able to re-use same public IP since its allocated from free IP pool. You can always re-use, re-attach elastic IP to other instance when it is released from current instance.
- You can not manually attach or detach public IP from instance. Its auto allocated from pool. Elastic IP can be manually attach and detach from instance.
- You can have maximum 5 elastic IP to your account per region. But, you can have as many public IPs as EC2 instances you spin up.
- You can have either of them for a instance. If you assign elastic IP to instance then its currently assigned publix IP will be released to free pool.