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:
Perform operations to change the public IP address of an ECS instance based on the type of the IP address and your business requirements.
To change the static public IP address of an ECS instance, perform the operations described in the Change the static public IP address of an ECS instance section of this topic.
To change the EIP of an ECS instance, perform the operations described in the Change the EIP of an ECS instance section of this topic.
If you want to convert the static public IP address of an ECS instance deployed in a virtual private cloud (VPC) into an EIP to improve the flexibility of network configuration, perform the operations described in Convert the public IP address of an ECS instance in a VPC to an EIP.
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.NoteIf 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.
NoteTo 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
Log on to the ECS console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region and resource group to which the resource belongs.
Find the ECS instance whose static public IP address you want to change. In the Actions column, choose
.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.
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.
ImportantYou 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.
Disassociate the EIP from the ECS instance.
For more information, see Disassociate an EIP from a cloud resource.
ImportantAfter 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.
For information about EIP configuration fees, see Pay-as-you-go.
For information about how to release a pay-as-you-go EIP, see Release a pay-as-you-go 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.
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
(Optional) Apply for a new EIP.
For more information, see Apply for an EIP.
Disassociate the current EIP from the ECS instance.
For more information, see Disassociate an EIP from a cloud resource.
ImportantAfter 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.
For information about EIP configuration fees, see Pay-as-you-go.
For information about how to release a pay-as-you-go EIP, see Release a pay-as-you-go 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.
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:
Reconfigure the security group rules that are associated with the ECS instance. For more information, see Modify a security group rule.
Monitor the network bandwidth or simulate real user access to monitor access to your website. For more information, see What is CloudMonitor? and Network Analysis and Monitoring.
Update the network permissions for Cloud Assistant or modify the Domain Name System (DNS) settings of Cloud Assistant. For more information, see Configure network permissions for Cloud Assistant Agent and Configure DNS settings for Cloud Assistant.
FAQ
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?
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.
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.