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 a conversation about AWS with one of my friends and he came up with the question what is the difference between elastic IP and public IP? So, I explained to him and thought why not draft a post about it! So in this article, we will see the difference between elastic IP and public IP in AWS. This can be a 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, let’s get basics clear. What is the elastic IP? It is IPv4 IP address designed and exists for dynamic cloud computing and reachable over the internet. By name, you can imagine it’s a flexible IP that can be used or mapped rapidly from one EC2 instance to another when a currently associated instance fails. This way end-user or application continues to talk to the same IP even if the 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 the internet. Remember switching flexibility of Elastic IP is not available for this IP. Amazon also assigns external/Public DNS name (shown in the screenshot) to instances who receives public IP. The public IP of the instance is mapped to the primary private IP of that instance via NAT (Network Address Translation) by default.
Refer below screenshot from the 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 let’s look at the difference between these two IP types.
- Whenever a new EC2 instance spins up, it’s 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 an instance is stopped and started again, public IP gets changed. But if the instance is assigned with elastic IP, it will remain the same even if the 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 an hourly basis.
- Public IP released once your instance is stopped so no question of getting charged for not using it.
- You won’t be able to re-use the same public IP since its allocated from the free IP pool. You can always re-use, re-attach elastic IP to other instances when it is released from the current instance.
- You can not manually attach or detach public IP from the instance. It’s auto allocated from the pool. Elastic IP can be manually attached and detach from the instance.
- You can have a maximum of 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 an instance. If you assign elastic IP to instance then its currently assigned public IP will be released to the free pool.
Quote from: https://kerneltalks.com/cloud-services/difference-between-elastic-ip-and-public-ip/