Stay organized with collections Save and categorize content based on your preferences.
This page describes how to migrate a VM instance from one network to another. In the case of a VM that is connected to more than one network using multiple network interfaces, this process updates one of the interfaces and leaves the rest in place.
The following migrations are supported:
In all cases, the VM stays in the region and zone where it was before. Only the attached network changes.
Before you beginSelect the tab for how you plan to use the samples on this page:
ConsoleWhen you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloudInstall the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update
.To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
Before you migrate a VM, it must meet the following requirements:
compute.subnetworks.useExternalIp
permission on the target network, and the target network cannot have external IP addresses disabled by the constraints/compute.vmExternalIpAccess constraint.Before you migrate a VM, review the requirements and limitations.
Google recommends that you create any necessary firewall rules, routes, load balancers, and other network infrastructure resources in the new network before migrating your VMs. Doing so can shorten the time that your VMs are offline.
Important: Migrating a VM can take several minutes. After you start migrating a VM, don't interrupt the process or modify any resources that Compute Engine is migrating.To migrate a VM, select one of the following options:
ConsoleIn the Google Cloud console, go to the VM instances page.
Click the VM instance name to open the details page.
If the VM is running, click stop Stop to stop the VM. If there is no Stop option, click more_vert More actions > stop Stop.
After the VM stops, click Edit edit.
Under Network interfaces, click the interface you want to move.
In the Network field of the interface, select the new network for the interface.
In the Subnetwork field of the interface, select the new subnet for the interface.
In the Internal IP address field, specify Automatic if you want the system to allocate an IP address from the subnet range or Custom if you want to specify an unused one yourself.
Click Done to close the network interface edit panel.
Click Save.
After the VM finishes saving, click Start start.
If a confirmation dialog appears, click Start.
Stop the VM
gcloud compute instances stop INSTANCE_NAME \ --zone=ZONE_NAME
where
Migrate the VM
gcloud compute instances network-interfaces update INSTANCE_NAME \ --zone=ZONE_NAME \ --network-interface=NIC \ --network=NETWORK_NAME \ --subnetwork=SUBNET_NAME
where
nic0
.projects/HOST_PROJECT_ID/global/networks/NETWORK_NAME
projects/HOST_PROJECT_ID/regions/REGION/subnetworks/SUBNET_NAME
Start the VM
Migration might take a few minutes, so wait before trying to start the VM in the new location.
gcloud compute instances start INSTANCE_NAME \ --zone=ZONE_NAME
where
Stop the VM
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE_NAME/instances/INSTANCE_NAME/stop
where
View details for the instance.
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE_NAME/instances/INSTANCE_NAME
where
Find the fingerprint for the interface.
You need the fingerprint to update the network interface.
Examine the output of the command and find the networkInterfaces
field contents. Find the item with the name of the interface you would like to update (in a single-interface VM, the name is nic0
). Copy the string in the fingerprint
field in this item for use in the next step.
Migrate the VM
PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE_NAME/instances/INSTANCE_NAME/updateNetworkInterface?networkInterface=NIC { "network": NETWORK_NAME, "subnetwork": SUBNET_NAME, "networkIP": IP_ADDRESS, "name": NIC, "fingerprint": FINGERPRINT }
nic0
.projects/HOST_PROJECT_ID/global/networks/NETWORK_NAME
projects/HOST_PROJECT_ID/regions/REGION/subnetworks/SUBNET_NAME
Start the VM
POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE_NAME/instances/INSTANCE_NAME/start
where
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["This document explains how to migrate a Virtual Machine (VM) instance's network interface from one network to another, including legacy to VPC, VPC to VPC, subnet to subnet, and service project to shared network migrations, all while keeping the VM in its original region and zone."],["VM migration requires the VM to be stopped, and it cannot be part of a managed instance group (MIG), although VMs in unmanaged instance groups or Network Endpoint Groups (NEGs) can be migrated after being removed from the group, and VMs in target pools can be moved directly."],["During migration, the VM's MAC address will change, and the internal IP address might change if the target subnet has a different IP range, although you can choose to keep the old IP address if it is available in the new location or specify a new one."],["You can migrate a VM's network interface using the Google Cloud console, `gcloud` command-line tool, or the REST API, with each method requiring the VM to be stopped before starting the migration process."],["While migrating a VM interface, it is mandatory to not have the target network be a legacy network and for the user to create necessary firewall rules, routes, load balancers and other network infrastructure in the new network before migrating the VM."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4