All Products
Search
Document Center

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

Last Updated:Apr 16, 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 IP address based on your business requirements in various scenarios, such as scenarios in which network security needs to be increased, the IP address is blocked, and resources are migrated. This topic describes how to change the public IP address of an ECS instance.

Background information

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

  • System-assigned public IP addresses

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

  • EIPs

    EIPs are static public IP addresses that you can purchase and use as independent resources. You can associate EIPs to and disassociate EIPs from ECS instances based on your business requirements. For more information, see What is an EIP?

The operations that you must perform to change the public IP address of an ECS instance vary based on the type of the public IP address that is associated with the instance.

View the type of the public IP address

To view the type of the public IP address that is associated with your ECS instance, perform the following steps:

  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 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, the instance uses a system-assigned public IP address.

      image

    • If EIP is displayed, the instance uses an EIP.

      image

Important

The operations that are described in this topic do not apply to an ECS instance to which a public IP address is not assigned by the system when the instance is created. You can change the public bandwidth of the ECS instance to allow the system to assign a 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.

Public IP address type

Period of time that elapsed after an ECS instance is created

Limit

Procedure

System-assigned public IP address

Within 6 hours

You can change the system-assigned public IP address of the instance up to three times if the following requirements are met:

  • A public IP address is assigned by the system to the instance.

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

    Note

    If an instance uses the pay-as-you-go billing method and resides in a VPC, you must enable the standard mode when you stop the instance. If you enable the economical mode, you may be unable to change the system-assigned public IP address of the instance.

Within 6 hours after an ECS instance is created

More than 6 hours

You cannot directly change the system-assigned public IP address of the ECS instance.

If you deploy the instance in a VPC, you can perform the following operations to allow the system to assign a new public IP address to the instance: Convert the original system-assigned public IP address of the instance into an EIP, disassociate the EIP from the instance, and then change the public bandwidth of the instance to a value greater than 1 Mbit/s.

More than 6 hours after an ECS instance is created

EIPs

Regardless of the period of time that elapsed after an ECS instance is created

  • The ECS instance must be deployed in a VPC.

  • The ECS instance must be in the Running or Stopped state.

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

  • The ECS instance is not associated with a system-assigned public IP address or an EIP.

Change the EIP of an ECS instance

Change the system-assigned public IP address of an ECS instance

Within 6 hours after an ECS instance is created

Important

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

  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 system-assigned 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 public IP address of the instance is changed, a new public IP address is displayed in the preceding message.

More than 6 hours after an ECS instance is created

  1. (Optional) If the ECS instance is a pay-as-you-go instance that uses the pay-by-bandwidth metering method for network usage, change the metering method for network usage to pay-by-traffic.

    For more information, 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 an auto-assigned IP address" topic.

  2. Convert the system-assigned public IP address of the ECS instance into an EIP.

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

  3. 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 avoid unnecessary charges, release the EIP.

    • If you no longer need a pay-as-you-go 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.

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

Change the EIP of an ECS instance

If your ECS instance uses an EIP instead of a system-assigned public IP address, perform the following operations to change the EIP of the instance:

  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 charges, release the EIP.

    • If you no longer need a pay-as-you-go 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 in the Chinese mainland and regions 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, you cannot access ECS instances in specific regions outside the Chinese mainland from specific regions in the Chinese mainland.

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

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

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

    No,

    you cannot convert the EIP into a system-assigned public IP address. After you convert a system-assigned 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 system-assigned public IP address or EIP of an ECS instance, the system randomly assigns an IP address to the instance.