Standardmäßig hat jede Compute-Instanz mindestens eine Netzwerkschnittstelle (vNIC), die das VPC-Netzwerk (Virtual Private Cloud) bestimmt, das von der Instanz verwendet wird. Sie können eine Instanz mit mehreren Netzwerkschnittstellen erstellen. Mit Ausnahme von VPC-Netzwerken, die mit einem RDMA-Netzwerkprofil erstellt wurden, muss jede Netzwerkschnittstelle einem Subnetz in einem eindeutigen VPC-Netzwerk zugewiesen werden. Der Stacktyp der Netzwerkschnittstelle und der Stacktyp des Subnetzes arbeiten zusammen, wie unter Stacktypen und IP-Adressen beschrieben.
Jede Compute-Instanz erhält eine Standardroute über DHCP-Option 121, wie in RFC 3442 definiert. Die Standardroute ist mit nic0
verknüpft. Sofern nicht manuell anders konfiguriert, wird sämtlicher Traffic, der von der Instanz zu beliebigen Zielen mit Ausnahme eines direkt verbundenen Subnetzes verläuft, über die Standardroute auf nic0
geleitet.
Auf Linux-Systemen können Sie benutzerdefinierte Regeln und Routen im Gastbetriebssystem mit der Datei /etc/iproute2/rt_tables
und den Befehlen ip rule
und ip route
konfigurieren. Weitere Informationen finden Sie in der Dokumentation zum Gastbetriebssystem. Ein Beispiel finden Sie in der Anleitung Routing für eine zusätzliche Schnittstelle konfigurieren.
Wenn Sie nicht mehrere Netzwerkschnittstellen benötigen, folgen Sie der Anleitung unter Instanz erstellen und starten, um Instanzen mit der Standardnetzwerkkonfiguration zu erstellen.
Hinweise
- Prüfen Sie vor dem Erstellen der Compute-Instanz, ob alle erforderlichen Netzwerke und Subnetze erstellt wurden. Informationen zum Erstellen von Netzwerken oder Subnetzen finden Sie unter VPC-Netzwerke erstellen und verwalten.
- Prüfen Sie, ob jedes Netzwerk über geeignete Firewallregeln verfügt, die den Datentransfer zu und von der Instanz mit mehreren Schnittstellen ermöglichen. Informationen zum Erstellen von Firewallregeln finden Sie unter VPC-Firewallregeln verwenden.
-
Wenn Sie eine Instanz mit mehreren Netzwerken über IPv6-Adressen verbinden, installieren Sie die
google-guest-agent
-Version 20220603.00 oder höher. Weitere Informationen finden Sie unter Ich kann keine Verbindung zur IPv6-Adresse einer sekundären Schnittstelle herstellen. -
Richten Sie die Authentifizierung ein, falls Sie dies noch nicht getan haben.
Bei der Authentifizierung wird Ihre Identität für den Zugriff auf Trusted Cloud by S3NS -Dienste und APIs überprüft.
Zum Ausführen von Code oder Beispielen aus einer lokalen Entwicklungsumgebung können Sie sich so bei der Compute Engine authentifizieren:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Trusted Cloud console to access Trusted Cloud by S3NS services and APIs, you don't need to set up authentication.
gcloud
-
Installieren Sie die Google Cloud CLI und melden Sie sich dann mit Ihrer föderierten Identität in der gcloud CLI an. Nach der Anmeldung initialisieren Sie die Google Cloud CLI mit folgendem Befehl:
gcloud init
- Set a default region and zone.
REST
Wenn Sie die REST API-Beispiele auf dieser Seite in einer lokalen Entwicklungsumgebung verwenden möchten, verwenden Sie die Anmeldedaten, die Sie der gcloud CLI bereitstellen.
Installieren Sie die Google Cloud CLI und melden Sie sich dann mit Ihrer föderierten Identität in der gcloud CLI an. Nach der Anmeldung initialisieren Sie die Google Cloud CLI mit folgendem Befehl:
gcloud init
Weitere Informationen finden Sie in der Dokumentation zur Trusted Cloud -Authentifizierung unter Für die Verwendung von REST authentifizieren.
Erforderliche Rollen
Bitten Sie Ihren Administrator, Ihnen die IAM-Rolle Compute-Instanzadministrator (v1) (
roles/compute.instanceAdmin.v1
) für das Projekt zu gewähren, um die Berechtigungen zu erhalten, die Sie zum Erstellen einer Instanz mit einem bestimmten Subnetz benötigen. Weitere Informationen zum Zuweisen von Rollen finden Sie unter Zugriff auf Projekte, Ordner und Organisationen verwalten.Diese vordefinierte Rolle enthält die Berechtigungen, die zum Erstellen einer Instanz mit einem bestimmten Subnetz erforderlich sind. Erweitern Sie den Abschnitt Erforderliche Berechtigungen, um die erforderlichen Berechtigungen anzuzeigen:
Erforderliche Berechtigungen
Die folgenden Berechtigungen sind erforderlich, um eine Instanz mit einem bestimmten Subnetz zu erstellen:
compute.instances.create
für das Projekt-
So geben Sie ein Subnetz für Ihre Instanz an:
compute.subnetworks.use
für das Projekt oder für das ausgewählte Subnetz -
So weisen Sie der Instanz eine externe IP-Adresse zu, wenn Sie ein VPC-Netzwerk verwenden:
compute.subnetworks.useExternalIp
für das Projekt oder für das ausgewählte Subnetz
Sie können diese Berechtigungen auch mit benutzerdefinierten Rollen oder anderen vordefinierten Rollen erhalten.
Voraussetzungen
Bevor Sie eine Instanz mit mehreren Netzwerkschnittstellen erstellen, sollten Sie die folgenden Anforderungen beachten:
- Mit Ausnahme von VPC-Netzwerken, die mit einem RDMA-Netzwerkprofil erstellt wurden, gilt die folgende Einschränkung: Wenn Sie eine Instanz mit mehreren Netzwerkschnittstellen erstellen, muss jede Schnittstelle mit einem anderen VPC-Netzwerk verbunden sein. Die Netzwerke können eigenständige VPC-Netzwerke oder freigegebene VPC-Netzwerke sein.
- Jede Netzwerkschnittstelle muss einen eindeutigen Subnetz-IP-Adressbereich verwenden.
- Bei Compute-Instanzen mit mehreren NICs in eigenständigen Projekten muss für jede Netzwerkschnittstelle ein Subnetz verwendet werden, das sich im selben Projekt wie die Instanz befindet. Informationen zu Instanzen in Host- oder Dienstprojekten mit freigegebener VPC finden Sie in der Virtual Private Cloud-Dokumentation unter Freigegebene VPC . Private Service Connect-Schnittstellen ermöglichen es einer Instanz mit mehreren NICs, Netzwerkschnittstellen in Subnetzen in verschiedenen Projekten zu haben. Weitere Informationen finden Sie unter Netzwerkanhänge.
VM-Instanzen mit mehreren Netzwerkschnittstellen erstellen
Bei den meisten Compute Engine-Instanzen können Sie beim Erstellen der Instanz mehrere vNICs konfigurieren.
- Informationen zur Anzahl der Netzwerkschnittstellen, die Sie für eine Instanz erstellen können, finden Sie unter Maximale Anzahl von Netzwerkschnittstellen.
- Sie können auch dynamische NICs konfigurieren, wenn Sie eine Instanz erstellen.
Informationen zum Erstellen einer Compute-Instanz mit mehreren Netzwerkschnittstellen finden Sie unter VM-Instanzen mit mehreren Netzwerkschnittstellen erstellen.
Einer vorhandenen Instanz Netzwerkschnittstellen hinzufügen
Sie können virtuelle NICs (vNICs) für eine Instanz nur beim Erstellen der Instanz konfigurieren. Sie können einer vorhandenen Instanz jedoch dynamische NICs hinzufügen oder daraus entfernen, ohne die Instanz neu starten zu müssen.
Dynamic NICs sind untergeordnete Schnittstellen einer übergeordneten vNIC. Wenn Sie eine dynamische NIC konfigurieren, geben Sie eine VLAN-ID an, mit der der Netzwerk-Traffic für die dynamische NIC getaggt wird:
- Die VLAN-ID einer Dynamic NIC muss eine Ganzzahl zwischen 2 und 255 sein.
- Die VLAN-ID einer Dynamic NIC muss innerhalb einer übergeordneten vNIC eindeutig sein. Dynamic NICs, die zu verschiedenen übergeordneten vNICs gehören, können jedoch dieselbe VLAN-ID verwenden.
Trusted Cloud by S3NS verwendet das folgende Format für den Namen einer dynamischen NIC:
PARENT_NIC_NUMBER.VLAN_ID
PARENT_NIC_NUMBER
ist der Name der übergeordneten vNIC, z. B.nic0
. DieVLAN_ID
ist die Nummer, die Sie bei der Konfiguration der dynamischen NIC angegeben haben. Ein Beispiel für einen dynamischen NIC-Namen istnic0.4
.Informationen zum Hinzufügen dynamischer NICs zu einer Instanz finden Sie unter Dynamische NICs zu einer Instanz hinzufügen.
Nächste Schritte
- SSH-Verbindungen verwenden, um eine Verbindung zu Ihrer Instanz herzustellen
- Über das interne DNS auf VMs zugreifen
- PTR-Eintrag für eine VM-Instanz erstellen
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2025-08-18 (UTC).
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-18 (UTC)."],[],[],null,["# Create VMs with multiple network interfaces\n\n*** ** * ** ***\n\nBy default, every compute instance has at least one network interface (vNIC)\nthat determines the Virtual Private Cloud network that the instance uses. You can\ncreate an instance with multiple network interfaces. Except for\nVPC networks that are created with an RDMA network profile, each\nnetwork interface must be assigned to a subnet in a unique VPC\nnetwork. The stack type of the network interface and the stack type of the\nsubnet work together as described in\n[Stack types and IP addresses](/vpc/docs/multiple-interfaces-concepts#stack-types)\n\nEach compute instance receives a default route using DHCP Option 121, as defined\nby [RFC 3442](https://datatracker.ietf.org/doc/html/rfc3442). The default route\nis associated with `nic0`. Unless manually configured otherwise, any traffic\nleaving an instance for any destination other than a directly connected subnet\nleaves the instance using the default route on `nic0`.\n\nOn Linux systems, you can configure custom rules and routes within the guest OS\nusing the `/etc/iproute2/rt_tables` file and the `ip rule` and `ip route`\ncommands. For more information, consult the guest OS documentation. For an\nexample, see the tutorial\n[Configure routing for an additional interface](/vpc/docs/configure-routing-additional-interface).\n\nIf you don't require multiple network interfaces, follow the procedure for\n[creating and starting an instance](/compute/docs/instances/create-start-instance)\nto create instances with the default network configuration.\n\nBefore you begin\n----------------\n\n- Verify that all required networks and subnets are created before you create the compute instance. If you need to create networks or subnets, see [Create and manage\n VPC networks](/vpc/docs/create-modify-vpc-networks).\n- Verify that each network has appropriate firewall rules that let data transfer to and from the instance that has multiple interfaces. If you need to create firewall rules, see [Use VPC firewall rules](/firewall/docs/using-firewalls).\n- If you are [connecting an\n instance to multiple networks by using IPv6 addresses](/vpc/docs/create-use-multiple-interfaces#example-dual), then install the `google-guest-agent` version [20220603.00](https://github.com/GoogleCloudPlatform/guest-agent/releases/tag/20220603.00) or later. For more information, see [I can't\n connect to a secondary interface's IPv6 address](/vpc/docs/troubleshoot-multiple-interfaces#connect-ipv6).\n- If you haven't already, set up [authentication](/compute/docs/authentication). Authentication verifies your identity 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:\n\n Select the tab for how you plan to use the samples on this page: \n\n ### Console\n\n\n When you use the Google Cloud console to access Google Cloud services and\n APIs, you don't need to set up authentication.\n\n ### gcloud\n\n 1.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n After installation,\n [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command:\n\n ```bash\n gcloud init\n ```\n\n\n If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n 2. [Set a default region and zone](/compute/docs/gcloud-compute#set_default_zone_and_region_in_your_local_client).\n\n ### REST\n\n\n To use the REST API samples on this page in a local development environment, you use the\n credentials you provide to the gcloud CLI.\n 1. [Install](/sdk/docs/install) the Google Cloud CLI. After installation, [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command: \n\n ```bash\n gcloud init\n ```\n 2. If you're using an external identity provider (IdP), you must first [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n\n For more information, see\n [Authenticate for using REST](/docs/authentication/rest)\n in the Google Cloud authentication documentation.\n\n### Required roles\n\n\nTo get the permissions that\nyou need to create an instance with a specific subnet,\n\nask your administrator to grant you the\n\n\n[Compute Instance Admin (v1)](/iam/docs/roles-permissions/compute#compute.instanceAdmin.v1) (`roles/compute.instanceAdmin.v1`)\nIAM role on the project.\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nThis predefined role contains\n\nthe permissions required to create an instance with a specific subnet. To see the exact permissions that are\nrequired, expand the **Required permissions** section:\n\n\n#### Required permissions\n\nThe following permissions are required to create an instance with a specific subnet:\n\n- ` compute.instances.create` on the project\n- To specify a subnet for your instance: ` compute.subnetworks.use` on the project or on the chosen subnet\n- To assign an external IP address to the instance when using a VPC network: ` compute.subnetworks.useExternalIp` on the project or on the chosen subnet\n\n\nYou might also be able to get\nthese permissions\nwith [custom roles](/iam/docs/creating-custom-roles) or\nother [predefined roles](/iam/docs/roles-overview#predefined).\n\nRequirements\n------------\n\nBefore you create an instance with multiple network interfaces, review the\nfollowing requirements:\n\n- Except for VPC networks that are created with an [RDMA network profile](/vpc/docs/rdma-network-profiles), the following limitation applies: If you create an instance with multiple network interfaces, each interface must connect to a different VPC network. The networks can be standalone [VPC networks](/vpc/docs/vpc) or [Shared VPC networks](/vpc/docs/shared-vpc).\n- Each network interface must use a unique subnet IP address range.\n- For multi-NIC compute instances in standalone projects, each network interface must use a subnet located in the same project as the instance. For instances in Shared VPC host or service projects, see [Shared VPC](/vpc/docs/multiple-interfaces-concepts#multiple-network-interfaces-in-shared-vpc) in the Virtual Private Cloud documentation. [Private Service Connect interfaces](/vpc/docs/about-private-service-connect-interfaces) provide a way for a multi-NIC instance to have network interfaces in subnets in different projects. For more information, see [About network attachments](/vpc/docs/about-network-attachments).\n\nCreate VM instances with multiple network interfaces\n----------------------------------------------------\n\nMost Compute Engine instances let you configure multiple vNICs when\ncreating the instance.\n\n- For information about the number of network interfaces you can create for an instance, see [Maximum number of network interfaces](/vpc/docs/multiple-interfaces-concepts#max-interfaces).\n- You can also configure [Dynamic NICs](/vpc/docs/multiple-interfaces-concepts#nic-types) when creating an instance.\n\nFor information about how to create a compute instance with multiple network\ninterfaces, see\n[Create VM instances with multiple network interfaces](/vpc/docs/create-use-multiple-interfaces#creating_virtual_machine_instances_with_multiple_network_interfaces).\n\nAdd network interfaces to an existing instance\n----------------------------------------------\n\nYou can configure virtual NICs (vNICs) for an instance only when creating the\ninstance. However, you can add or remove\n[Dynamic NICs](/vpc/docs/multiple-interfaces-concepts#nic-types)\nto an existing instance, and you don't have to restart the instance.\n\nDynamic NICs are subinterfaces of a parent vNIC.\nWhen you configure a Dynamic NIC, you specify\na VLAN ID that is used to tag network traffic for the\nDynamic NIC:\n\n- The VLAN ID of a Dynamic NIC must be an integer from 2 to 255.\n- The VLAN ID of a Dynamic NIC must be unique within a parent vNIC. However, Dynamic NICs that belong to different parent vNICs can use the same VLAN ID.\n\nGoogle Cloud uses the following format for the name of a\nDynamic NIC:\n\u003cvar translate=\"no\"\u003ePARENT_NIC_NUMBER\u003c/var\u003e`.`\u003cvar translate=\"no\"\u003eVLAN_ID\u003c/var\u003e\n\n\u003cvar translate=\"no\"\u003ePARENT_NIC_NUMBER\u003c/var\u003e is the name of the parent vNIC, for example\n`nic0`. The \u003cvar translate=\"no\"\u003eVLAN_ID\u003c/var\u003e is the number you specified when\nconfiguring the Dynamic NIC. An example\nDynamic NIC name is `nic0.4`.\n\nFor information about how to add Dynamic NICs to an\ninstance, see\n[Add Dynamic NICs to an instance](/vpc/docs/add-dynamic-nics).\n\nWhat's next?\n------------\n\n- Learn how to use [SSH connections](/compute/docs/instances/ssh) to connect to your instance.\n- [Access VMs using internal DNS](/compute/docs/networking/using-internal-dns)\n- [Create a PTR record for a VM instance](/compute/docs/instances/create-ptr-record)"]] -