[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-19。"],[],[],null,["# Change the MTU setting of a VPC network\n=======================================\n\nIn Google Cloud, you set the MTU for each VPC network.\nVirtual machine (VM) instances that use that network must be configured to use\nthe same MTU setting for their interfaces.\n\n- Linux VMs based on [public OS images](/compute/docs/images/os-details) receive\n the VPC network's MTU setting from the DHCP server. DHCP Option\n 26 contains the MTU setting.\n\n- Windows VMs do not use DHCP to configure the MTU setting. If you change the\n MTU of a VPC network, you must [change the MTU setting of the\n VM](#change-mtu-windows).\n\nFor more information about VMs and MTU settings, see [VMs and MTU\nsettings](/vpc/docs/mtu#vms_and_mtu_settings).\n\nThere are two ways to start using a VPC network with a different\nMTU setting:\n\n- You can [change the MTU setting](#change-mtu) of an existing VPC\n network, which requires that you shut down all VMs in the network at the same\n time.\n\n- You can create a new VPC network with a different MTU setting,\n and [migrate the VMs to it](#migrate-vms-mtu) to it.\n\nChange the MTU of a network\n---------------------------\n\nEach VPC network has an MTU. Do not change the network MTU while\nthe VMs are running. Doing so can result in a period where VMs have different\nMTUs, which can lead to unreliable network connectivity.\n\nFor detailed considerations regarding changing the MTU of a network, see the\n[maximum transmission unit overview](/vpc/docs/mtu).\n\nThe recommended way to update the network MTU is to stop all running VM\ninstances, change the network MTU, then start all instances. VMs based on\npublic Linux images automatically configure each of their network\ninterfaces to use the MTU of the attached VPC network when they\nstart. You must manually [update the MTU of Windows VMs](#change-mtu-windows)\nand VMs based on custom images that do not rely on DHCP for network MTU\nconfiguration. \n\n### Console\n\nUpdating network MTU is not supported in the Google Cloud console.\nSee the Google Cloud CLI or API instructions.\n\n### gcloud\n\n1. Stop all VMs.\n\n For each zone in the network, stop all VMs in that zone. \n\n ```\n gcloud compute instances stop INSTANCE_NAMES... \\\n --zone=ZONE\n ```\n2. Update network MTU.\n\n ```\n gcloud compute networks update NETWORK \\\n --mtu=MTU\n ```\n3. Start all VMs.\n\n For each zone in the network, start all VMs in that zone. \n\n ```\n gcloud compute instances start INSTANCE_NAMES... \\\n --zone=ZONE\n ```\n\n Replace the placeholders with valid values:\n - \u003cvar translate=\"no\"\u003eINSTANCE_NAMES...\u003c/var\u003e is a space-separated list of instances.\n - \u003cvar translate=\"no\"\u003eNETWORK\u003c/var\u003e is the name of the VPC network whose dynamic routing mode you need to change.\n - \u003cvar translate=\"no\"\u003eMTU\u003c/var\u003e specifies whether the network has an MTU of `1460` (default), `1500`, or `8896`. Review the [maximum\n transmission unit overview](/vpc/docs/mtu) before setting the MTU to higher than `1460`.\n\n### API\n\nChange the MTU of an existing VPC network. \n\n```\nPATCH https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/networks/NETWORK\n{\n \"mtu\": MTU\n}\n```\n\nReplace the placeholders with valid values:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e is the ID of the project that contains the VPC network to modify.\n- \u003cvar translate=\"no\"\u003eNETWORK\u003c/var\u003e is the name of the VPC network to modify.\n- \u003cvar translate=\"no\"\u003eMTU\u003c/var\u003e is the maximum transmission unit of the network. MTU can be set to anything from `1300` through `8896` (default: `1460`). Review the [maximum transmission unit overview](/vpc/docs/mtu) before setting the MTU to higher than `1460`.\n\nFor more information, refer to the\n[`subnetworks.patch`](/compute/docs/reference/rest/v1/subnetworks/patch)\nmethod.\n\nChange the MTU setting of a Windows VM\n--------------------------------------\n\nWindows VMs based on [public OS images](/compute/docs/images/os-details) are\nconfigured with a fixed MTU of `1460`. Custom Windows VMs might have different\nMTU settings.\n\nTo set Windows VMs to use a different MTU, do the following on each VM:\n**Note:** You can set custom MTU sizes ranging from 576 to 4080 for gVNIC network adapters, but jumbo frames (setting the MTU to `8896`) is available only for the Virt-IO network adapter. To use jumbo frames with gVNIC on supported [third generation](/compute/docs/machine-resource#vm_terminology) and later machine series (except for N4), you can [update to the latest gVNIC driver for Windows](/compute/docs/networking/using-gvnic#manual-gvnic-setup). \n\n### Command prompt\n\n1. Open Command Prompt (cmd.exe) as Administrator.\n2. Run the following command to determine the index of the interface that you\n want to update:\n\n ```\n netsh interface ipv4 show interface \n ```\n3. Update the interface:\n\n ```\n netsh interface ipv4 set interface INTERFACE_INDEX mtu=MTU store=persistent \n ```\n4. Update the device driver configuration:\n\n 1. Open the Device Manager with following command: \n\n ```\n devmgmt.msc\n ```\n 2. Expand the **Network adapters** category.\n 3. Right-click the **Google VirtIO Ethernet Adapter** /**Google Ethernet Adapter** device.\n 4. Select **Properties**.\n 5. Click the **Advanced** tab.\n 6. In the **Init.MTUSize** field, enter the MTU setting.\n 7. Click **OK**.\n\n The instance briefly loses connectivity, because the driver\n automatically restarts when the registry entries change.\n\n### PowerShell\n\n1. Open PowerShell as Administrator.\n2. Run the following command:\n\n ```\n Set-NetIPInterface -InterfaceAlias INTERFACE_NAME -AddressFamily IPv4 -NlMtu MTU \n ```\n3. Run the following command to update device driver settings:\n\n ```\n Set-NetAdapterAdvancedProperty -Name \"Ethernet\" -RegistryKeyword MTU -RegistryValue MTU \n ```\n\n You will briefly lose connectivity to the VM, because the driver\n automatically restarts when the registry entries change.\n\nMigrate VMs to a different MTU network\n--------------------------------------\n\nYou might decide to migrate your services to new VMs in a new network rather\nthan changing the MTU of your existing network. In such a case, you might have a\nserver, such as a database server, that needs to be accessible to all VMs during\nthe migration. If so, the following general approach might help you migrate\ncleanly:\n\n1. [Create the new network](/vpc/docs/create-modify-vpc-networks#create-custom-network) with the new MTU.\n2. Create any necessary firewall rules and routes in the new network.\n3. [Create a VM with multiple network\n interfaces](/vpc/docs/create-use-multiple-interfaces#creating_virtual_machine_instances_with_multiple_network_interfaces) in the old network. One interface connects to the new network using the new MTU and the other connects to the old network using the old MTU.\n4. Configure this new VM as a secondary server for the existing one.\n5. Fail the primary server over to the secondary one.\n6. Either [Migrate VMs to the new\n network](/compute/docs/instances/migrating-interfaces-between-networks) or create new VMs in the new network. If you create new VMs, you can create them from scratch, from an existing image, or by [creating a\n snapshot](/compute/docs/disks/create-snapshots) of the existing VMs and using that to populate the new persistent disks.\n7. Configure these VMs to use the operational server in that network.\n8. Migrate traffic to the new VMs.\n9. If you intend to delete the old network, create a new server in the new network, get it in sync with the existing server, and fail over to it.\n10. Delete the old server and old network.\n\nTry it for yourself\n-------------------\n\n\nIf you're new to Google Cloud, create an account to evaluate how\nVPC performs in real-world\nscenarios. New customers also get $300 in free credits to run, test, and\ndeploy workloads.\n[Try VPC free](https://console.cloud.google.com/freetrial)"]]