×
Community Blog Public IP vs Elastic IP: What Is the Best Choice?

Public IP vs Elastic IP: What Is the Best Choice?

This article explains how to choose between a Public IP and an Elastic IP (EIP).

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).

What Is a Public IP?

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.

What Is an Elastic IP (EIP)?

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.

Use Case Scenarios

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.

Benefits

Elastic IP

  • It is constant, meaning it won't change
  • It is movable, meaning you can move it from instance to instance as needed. You can associate an EIP with a cloud resource as needed. You can also disassociate and release an EIP as needed to prevent unexpected charges.
  • It offers high availability, eliminating single points of failure and supporting cross-zone disaster recovery and automatic failover.
  • It supports multiple billing methods, including subscription, pay-by-bandwidth, and pay-by-data-transfer. You can reduce bandwidth costs after you associate an EIP with an EIP bandwidth plan.
  • It supports contiguous IP addresses and allows you to retrieve specific IP addresses you have released.
  • It supports VPC networks.

Public IP

  • There is no cost for short projects since it is automatically attached to your instance and released when the instance is terminated.
  • It supports VPC and Classic networks.

What Is the Best Choice?

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.

0 0 0
Share on

Alibaba Cloud Community

1,076 posts | 263 followers

You may also like

Comments