每个 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
-
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.
- Set a default region and zone.
- 如需更新网络接口所属的网络或子网,请参阅在网络之间迁移虚拟机。
- 如需更新 IP 堆栈类型,请参阅更改实例的堆栈类型。
- 如需更新 IP 地址,请参阅以下内容:
- 如需更新别名 IP 范围,请参阅修改现有实例的别名 IP 范围。
- 如需更新网络边缘安全政策,请参阅配置网络边缘安全政策。
- 了解如何为 VPC 网络创建和管理路由。
- 了解如何扩缩虚拟机并通过负载均衡优化应用延迟时间。
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。后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-29。
-