By Alain Francois
When hosting your services on the cloud, you need your services to be reachable. However, depending on some requirements, you need to be careful about the type of IP you need to assign. Major cloud providers offer some types of IP addresses that you can assign to your cloud instances, such as the Public IP and the Elastic IP (EIP).
A Public IP is an address that can be reached from the Internet. It is assigned to your launched instance. When the instance is terminated, the Public IP attached to it gets released. Furthermore, when you relaunch the same instance, a new IP address is assigned.
When a Public IP address is disassociated from your instance, it is released back into the pool and is no longer available for you to use. You cannot manually associate or disassociate a Public IP address, which is why when a Public IP is released from your instance, it is assigned to a new one.
An Elastic IP is a NAT IP address located in the Internet gateway of Alibaba Cloud and mapped to the associated cloud resource through NAT. After a cloud resource is associated with an EIP, the cloud resource can communicate with the Internet through the EIP. An Elastic IP address is static and designed for dynamic cloud computing. Elastic IPs do not change. They remain the same even if you terminate the instance and restart the same instance again later.
Public IP is used when you are working on small projects where you use an IP for a short time. If you want an instance to have a Public IP address that will not be retained when the instance is released, you can configure a Public IP address to be automatically assigned when you create the instance.
Let's say you are trying to run a service that your collaborators will need to use once for a specific time. You can use the Public IP because it does not matter if the IP changes after the defined period, as the service will no longer be needed.
So, you can use the Public IP for services you want to use for a limited period. For example, if you need to set up some labs for a training session, you can share the IP address with the trainees to make sure they cannot access the instance after the defined period. They can share it, but you can use an IP that can change afterward.
Elastic IP is used when you are working on a long-time project, and the configuration of IP sometimes consumes more time. If you want to retain a Public IP address after its associated instance is released for use with other ECS instances, use an EIP. Each EIP can be associated with or disassociated from different ECS instances. After an instance is released, its associated EIP is retained.
Let’s say you have a web server hosting your website. You may need to scale up that machine because of traffic or simultaneous requests. You may also need to stop that machine to fix something. If the IP changes, it means you will have to update the DNS record every time for such operations. With an EIP, you can maintain your IP address and communication with your cloud account.
You need to configure a VPN connection with your instance to have stable communication. You need to have an IP that will not change if you restart your instance since you need to update the configuration every time.
Let's say that you have a lot of ECS instances that you want to organize by group. If you move an instance with an EIP, you can detach the EIP that you will reassign to another instance.
You can also associate multiple EIPs with a single ECS instance in a multi-EIP to Elastic Network Interface (ENI) mode.
A Public IP address of an instance will change if this one is stopped. However, if you require a persistent Public IP address that can be assigned to and removed from instances, use an Elastic IP address instead. Most people prefer using the EIP, but it depends on your needs. Check your use case scenario and see if it fits your needs.
In conclusion, Elastic IPs get allocated to your account and stay the same, but Public IPs do not. You can also choose whether or not to attach EIPs to an instance.
On-Cloud Development - Alibaba DevOps Practice Guide Part 10
1,037 posts | 255 followers
FollowAlibaba Cloud Community - March 31, 2022
Alibaba Clouder - May 6, 2019
Alibaba Clouder - June 7, 2018
Alibaba Cloud Community - November 29, 2021
Alibaba Clouder - July 15, 2019
Alibaba Clouder - September 21, 2018
1,037 posts | 255 followers
FollowAn independent public IP resource that decouples ECS and public IP resources, allowing you to flexibly manage public IP resources.
Learn MoreMigrate to the cloud with your own IP addresses.
Learn MoreHighly reliable and secure deployment solutions for enterprises to fully experience the unique benefits of the hybrid cloud
Learn MoreThis solution helps Internet Data Center (IDC) operators and telecommunication operators build a local public cloud from scratch.
Learn MoreMore Posts by Alibaba Cloud Community