Update the network interfaces for an instance


Every Compute Engine instance has a nic0 virtual network interface (vNIC) connected to a subnet in a VPC network. Depending on the instance's machine type, you can define additional vNICs only when you create a instance.

With Dynamic Network Interfaces (Preview), you can create VLAN-based subinterfaces for each vNIC, which lets you scale the number of network interfaces and VPC network connections.

You can add or remove Dynamic NICs without having to restart or recreate the instance. For more information, see the following pages in the Virtual Private Cloud (VPC) documentation:

This page describes how to update the properties of the network interface of an instance.

Before you begin

  • If you haven't already, then set up authentication. Authentication is the process by which your identity is verified for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:

    Select the tab for how you plan to use the samples on this page:

    Console

    When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.

    gcloud

    1. After installing the Google Cloud CLI, initialize it 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.

    2. Set a default region and zone.

    REST

    To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.

      After installing the Google Cloud CLI, initialize it 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.

Update a network interface of an instance

To update the properties of a network interface, see the procedure that corresponds to the property that you want to update, such as one of the following.

If you are updating a Dynamic NIC (Preview), you must use the gcloud beta compute instances network-interfaces update command or the beta version of the instances.updateNetworkInterface method. Additionally, ensure that you specify Dynamic NICs according to the naming format of Dynamic NICs.

What's next