更新实例的网络接口


每个 Compute Engine 实例都有一个 nic0 虚拟网络接口 (vNIC),该接口连接到 VPC 网络中的子网。根据实例的机器类型,您只能在创建实例时定义其他 vNIC。

借助 Dynamic Network Interface(预览版),您可以为每个 vNIC 创建基于 VLAN 的子接口,从而扩缩网络接口和 VPC 网络连接的数量。

您可以添加或移除 Dynamic NIC,而无需重启或重新创建实例。如需了解详情,请参阅虚拟私有云 (VPC) 文档中的以下页面:

本页面介绍了如何更新实例网络接口的属性。

准备工作

  • 如果您尚未设置身份验证,请进行设置。身份验证是通过其进行身份验证以访问 Google Cloud 服务和 API 的过程。如需从本地开发环境运行代码或示例,您可以通过选择以下选项之一向 Compute Engine 进行身份验证:

    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.
      3. REST

        如需在本地开发环境中使用本页面上的 REST API 示例,请使用您提供给 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.

        如需了解详情,请参阅 Google Cloud 身份验证文档中的使用 REST 时进行身份验证

更新实例的网络接口

如需更新网络接口的属性,请参阅与您要更新的属性对应的过程,例如以下步骤之一。

如果您要更新 Dynamic NIC(预览版),则必须使用 gcloud beta compute instances network-interfaces update 命令instances.updateNetworkInterface 方法的 Beta 版。此外,请确保您根据 Dynamic NIC 的命名格式指定 Dynamic NIC。

后续步骤