Change the MTU setting of a VPC network (original) (raw)

In Google Cloud, you set the MTU for each VPC network. Compute Engine instances that use that network must be configured to use the same MTU setting for their interfaces.

For more information, seeCompute instances and MTU settings.

There are two ways to start using a VPC network with a different MTU setting:

Before you begin

Change the MTU setting of a VPC network

To update a VPC network MTU, do the following:

Stop all compute instances

You can stop multiple compute instances simultaneously by using the Google Cloud console. To display all instances in a given network, on theCompute Engine VM instances page use the filter bar to filter by the Network property, and then select your network.

You can stop multiple instances that are in the same zone simultaneously by using the gcloud CLI.

For more information about stopping instances, including considerations for instances with local SSDs, see Stop or restart a Compute Engine instance.

Update the network MTU

Ensure that you have stopped all compute instances before you change the VPC network MTU.

Console

Updating network MTU is not supported in the Google Cloud console. See the Google Cloud CLI or API instructions.

gcloud

Update network MTU by using the gcloud compute networks updatecommand.

gcloud compute networks update NETWORK
--mtu=MTU

Replace the following:

API

Change the MTU of an existing VPC network.

PATCH https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/networks/NETWORK { "mtu": MTU }

Replace the following:

For more information, see thenetworks.patch method.

Start compute instances

You can start multiple compute instances simultaneously by using the Google Cloud console. To display all instances in a given network, use the filter bar to filter by the Network property, and then select your network.

You can start multiple instances that are in the same zone simultaneously by using the gcloud CLI.

For more information about starting instances, see Stop or restart a Compute Engine instance.

Change the MTU setting of Windows instances

Windows instances based on public OS imagesare configured with a fixed MTU of 1460. Custom Windows instances might have different MTU settings.

To set Windows instances to use a different MTU, do the following on each instance:

Command prompt

  1. Open Command Prompt (cmd.exe) as Administrator.
  2. Run the following command to determine the index of the interface that you want to update:
    netsh interface ipv4 show interface
  3. Update the interface:
    netsh interface ipv4 set interface INTERFACE_INDEX mtu=MTU store=persistent
  4. Update the device driver configuration:
    1. Open the Device Manager with following command:
      devmgmt.msc
    2. Expand the Network adapters category.
    3. Right-click the Google VirtIO Ethernet Adapter/Google Ethernet Adapter device.
    4. Select Properties.
    5. Click the Advanced tab.
    6. In the Init.MTUSize field, enter the MTU setting.
    7. Click OK.
      The instance briefly loses connectivity, because the driver automatically restarts when the registry entries change.

PowerShell

  1. Open PowerShell as Administrator.
  2. Run the following command:
    Set-NetIPInterface -InterfaceAlias INTERFACE_NAME -AddressFamily IPv4 -NlMtu MTU
  3. Run the following command to update device driver settings:
    Set-NetAdapterAdvancedProperty -Name "Ethernet" -RegistryKeyword MTU -RegistryValue MTU
    The instance briefly loses connectivity, because the driver automatically restarts when the registry entries change.

Migrate compute instances to a different MTU network

You might decide to migrate your services to new compute instances in a new network rather than changing the MTU of your existing network. In such a case, you might have a server, such as a database server, that needs to be accessible to all instances during the migration. If so, the following general approach might help you migrate cleanly:

  1. Create the new network with the new MTU.
  2. Create any necessary firewall rules and routes in the new network.
  3. Create a VM with multiple network interfacesin 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.
  4. Configure this new instance as a secondary server for the existing one.
  5. Fail the primary server over to the secondary one.
  6. Either Migrate VMs to the new network or create new instances in the new network. If you create new instances, you can create them from scratch, from an existing image, or by creating a snapshot of the existing instances and using that to populate the new persistent disks.
  7. Configure these instances to use the operational server in that network.
  8. Migrate traffic to the new instances.
  9. 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.
  10. Delete the old server and old network.

Try it for yourself

If you're new to Google Cloud, create an account to evaluate how VPC performs in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.

Try VPC free