All Products
Search
Document Center

Elastic Compute Service:Change the public IP address of an ECS instance

Last Updated:Oct 30, 2024

If a public IP address is associated with an Elastic Compute Service (ECS) instance that is deployed in the classic network or a virtual private cloud (VPC), you can change the public IP address based on your business requirements, such as when you want to improve network security, replace a blocked IP address, and migrate resources. This topic describes how to change the public IP address of an ECS instance.

Background information

Public IP addresses include static public IP addresses and elastic IP addresses (EIPs). Static public IP addresses are also called system-assigned or auto-assigned public IP addresses. Both static public IP addresses and EIPs can provide access to your services over the Internet.

  • Static public IP addresses

    When ECS instances are created in VPCs, static public IP addresses can be automatically assigned by the system to the instances. You cannot disassociate the static public IP addresses from the ECS instances.

  • EIPs

    EIPs are public IP addresses that can be purchased and used as independent resources. You can associate EIPs with and disassociate EIPs from ECS instances based on your business requirements. For more information, see What is an Elastic IP Address?

Check the type of the public IP address of an ECS instance

The required operations to change the public IP address of an ECS instance vary based on the type of the IP address. To check whether the public IP address of an ECS instance is a static public IP address or an EIP, perform the following operations:

View the type of the public IP address

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Instances & Images > Instances.

  3. In the top navigation bar, select the region and resource group to which the resource belongs. 地域

  4. Find the ECS instance whose public IP address you want to change and view the type of the public IP address in the IP Address column.

    • If Public is displayed to the right of an IP address, the IP address is a static public IP address.

      image

    • If EIP is displayed to the right of an IP address, the IP address is an EIP.

      image

Perform operations to change the public IP address of an ECS instance based on the type of the IP address and your business requirements.

Change the static public IP address of an ECS instance

Within 6 hours of instance creation

You can change the static public IP address of an ECS instance in the ECS console within 6 hours after the instance is created.

Prerequisites

  • The ECS instance is in the Stopped (Stopped) state.

    Note

    If the ECS instance is a pay-as-you-go instance that is deployed in a VPC, you must stop the instance in standard mode. If you stop the instance in economical mode, you may be unable to change the static public IP address of the instance. For more information, see Economical mode.

  • You can change the static public IP address of an ECS instance up to three times within 6 hours after the instance is created.

    Note

    To change the static public IP address of an ECS instance for the fourth time within 6 hours after the instance is created, perform the operations described in the More than 6 hours of instance creation section of this topic.

Procedure

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Instances & Images > Instances.

  3. In the top navigation bar, select the region and resource group to which the resource belongs. 地域

  4. Find the ECS instance whose static public IP address you want to change. In the Actions column, choose icon1 > Network and Security Group > Change Public IP Address.

  5. In the Change Public IP Address message, confirm the information and click Confirm.

    When the static public IP address of the instance is changed, a new static public IP address is displayed in the preceding message.

More than 6 hours of instance creation

You cannot directly change the static public IP address of an ECS instance more than 6 hours after the instance is created.

  1. If the instance is not a subscription instance that uses the pay-by-bandwidth billing method for network usage, you can convert the static public IP address of the instance into an EIP.

    For more information, see Convert the public IP address of an instance in a VPC to an EIP.

    Important
    • You cannot change the static public IP address of a subscription ECS instance within 24 hours before the instance expires.

    • For a subscription ECS instance that uses the pay-by-bandwidth billing method for network usage, you can change the billing method for network usage to pay-by-traffic before you change the static public IP address of the instance. For information about how to change the billing method for network usage from pay-by-bandwidth to pay-by-traffic, see the Change from pay-by-bandwidth to pay-by-traffic section of the "Change the billing method for network usage of an ECS instance that uses a static public IP address" topic.

  2. Disassociate the EIP from the ECS instance.

    For more information, see Disassociate an EIP from a cloud resource.

    Important
    • After you disassociate a pay-as-you-go EIP from a cloud resource, you are still charged an EIP configuration fee. To prevent unnecessary fees, release the EIP.

    • If you no longer require a subscription EIP after you disassociate the EIP from a cloud resource, you can unsubscribe from the EIP. For more information, see Rules for unsubscribing from resources.

  3. Change the public bandwidth of the ECS instance to a value greater than 1 Mbit/s to allow the system to assign a new public IP address to the instance.

    For more information, see Modify the bandwidth configurations of subscription instances or Modify the bandwidth configurations of pay-as-you-go instances.

    You can view the new static public IP address in the IP Address column on the instance list page. For more information, see the View the type of the public IP address section of this topic.

Change the EIP of an ECS instance

To change the EIP that is associated with an ECS instance, disassociate the EIP from the instance and associate a different EIP with the instance.

Prerequisites

  • The ECS instance is deployed in a VPC.

  • The ECS instance is in the Running or Stopped state.

  • The ECS instance and the EIP that you want to associate with the instance are in the same region.

  • The ECS instance is not associated with a static public IP address or EIPs other than the current EIP.

Procedure

  1. (Optional) Apply for a new EIP.

    For more information, see Apply for an EIP.

  2. Disassociate the current EIP from the ECS instance.

    For more information, see Disassociate an EIP from a cloud resource.

    Important
    • After you disassociate a pay-as-you-go EIP from a cloud resource, you are still charged an EIP configuration fee. To avoid unnecessary fees, release the EIP.

    • If you no longer require a subscription EIP after you disassociate the EIP from a cloud resource, you can unsubscribe from the EIP. For more information, see Rules for unsubscribing from resources.

  3. Associate the new EIP with the ECS instance.

    For more information, see Associate an EIP with an ECS instance.

References

After you change the public IP address of an ECS instance, you may need to perform the following operations:

FAQ

  1. Can I change the public IP address of an ECS instance in a region outside the Chinese mainland to resolve the high latency issue that occurs when I access the instance from the Chinese mainland?

    No, you cannot change the public IP address of the ECS instance to resolve the high latency issue.

    Cross-border communication between regions inside and outside the Chinese mainland may be affected by connection congestion and the regulations of Internet service providers (ISPs), which may lead to network link instability and cause packet loss or other exceptions. As a result, ECS instances in specific regions outside the Chinese mainland are inaccessible to users from specific regions inside the Chinese mainland.

    • If you provide services for users in the Chinese mainland, we recommend that you deploy ECS instances in a region inside the Chinese mainland to bypass the limitations of cross-border communication.

    • If you want to allow users in regions inside the Chinese mainland to access ECS instances in regions outside the Chinese mainland, we recommend that you use Global Accelerator (GA). For more information, see What is GA?

  2. After I convert a static public IP address into an EIP, can I convert the EIP into a static public IP address?

    No, you cannot convert the EIP into a static public IP address.

    The conversion of a static public IP address into an EIP is irreversible. After you convert a static public IP address into an EIP, you are charged for the EIP based on the billing method of the EIP. For more information, see Billing overview.

  3. Can I specify an IP address as the public IP address when I change the public IP address of an ECS instance?

    No, you cannot specify an IP address as the public IP address when you change the public IP address of an ECS instance.

    When you change the static public IP address or EIP of an ECS instance, the system randomly assigns an IP address to the instance.