Change the vSwitch when the current vSwitch runs out of available IP addresses, or when you need to migrate an Elastic Compute Service (ECS) instance to a different CIDR block as part of a network architecture upgrade. With this feature, you can:
Move an instance's primary Elastic Network Interface (ENI) to a different vSwitch within the same virtual private cloud (VPC) and availability zone
Specify a new private IP address from the destination vSwitch's CIDR block, or have one assigned automatically
Potential impacts
Before proceeding, review the following impacts:
Service interruption: The instance must be stopped before you can change its vSwitch.
Private IP address change: The primary private IP address changes to a new address from the destination vSwitch's CIDR block. Any application or service that relies on the original IP address—such as database connection strings, firewall allowlists, or other service configurations—will stop working. Update those configurations after the change.
Public IP address: Remains unchanged.
Connectivity loss (static IP only): If the instance uses a static IP address, the internal network settings (IP address, subnet mask, and default gateway) will no longer match after the vSwitch change, preventing you from connecting to the instance. To avoid this, reconfigure the OS to use DHCP before changing the vSwitch.
Network ACL rules: If the source and destination vSwitches have different network ACL rules, review and update them to keep your applications working correctly.
Route configuration: If your application relies on specific routing rules, the new vSwitch may have a different routing configuration. Verify connectivity by associating a custom route table with the destination vSwitch and configuring the necessary route entries.
Prerequisites
Before you begin, ensure that you have:
Stopped the instance. The instance must not be in Locked status. See Stop an instance.
(If the primary ENI has secondary IP addresses) Unassigned all secondary private IPv4 addresses from the primary ENI, and deleted all assigned IPv6 addresses.
(If the instance uses a static IP address) Reconfigured the OS to use DHCP so the instance can automatically obtain an IP address, subnet mask, and default gateway after the vSwitch change. See the DHCP configuration steps below.
Configure DHCP on a Linux instance
Configure DHCP on a Windows instance
The following steps use Windows Server 2022 as an example.
Open Network and Sharing Center.
Click Change adapter settings.
Double-click the primary ENI named Ethernet, then click Properties.

In the Ethernet Properties dialog box, double-click Internet Protocol Version 4 (TCP/IPv4).

Select Obtain an IP address automatically, then click OK.

Change the vSwitch
Console
Go to the ECS console - Instances page. In the top navigation bar, select the target region and resource group.
Click the ID of the instance whose vSwitch you want to change.
On the instance details page, click All Actions > Network and Security Group > Change vSwitch in the upper-right corner.
Select a destination vSwitch.
Set the private IP address for the instance on the new vSwitch:
Specify an IP address: Enter an IP address within the destination vSwitch's CIDR block in the Private IP Address field. Use this option to minimize reconfiguration—for example, if you can allocate the same IP from the new subnet, downstream dependencies such as connection strings and allowlists do not need to change.
Auto-assign: Leave the Private IP Address field blank. An available address from the destination vSwitch's CIDR block is assigned automatically.
Confirm the change.
After the change is complete, the new vSwitch appears in the Configuration Information section on the Instance Details page.
The instance does not start automatically after the vSwitch change. Start it manually.
API
Call ModifyInstanceVpcAttribute to change the vSwitch of an ECS instance's primary ENI.
To verify the change, call DescribeInstances and check the VSwitchId field in the response.
After the change, call StartInstance to start the instance.
FAQ
How do I convert between CIDR format and IP address ranges?
See Examples of converting CIDR blocks to IP address ranges. You can also run ipcalc on an instance in the destination vSwitch to view the IP address range directly.
How do I reconfigure secondary private IPv4 or IPv6 addresses after changing the vSwitch?
After the change, assign secondary private IPv4 and IPv6 addresses from the new vSwitch's CIDR block. See Assign a secondary private IP address to an ENI and Configure an IPv6 address.
What's next
To connect ECS instances across different accounts or VPCs, use a VPC peering connection for direct one-to-one peering, or use Cloud Enterprise Network (CEN) for large-scale network interconnection. See Cross-VPC interconnection overview.
To migrate an ECS instance to another availability zone in the same region, see Cross-zone migration.
To migrate an ECS instance to another account or region, see Migrate ECS instances between accounts or within the same account.