Per impostazione predefinita, ogni istanza di computing ha almeno un'interfaccia di rete (vNIC) che determina la rete Virtual Private Cloud utilizzata dall'istanza. Puoi creare un'istanza con più interfacce di rete. Ad eccezione delle reti VPC create con un profilo di rete RDMA, ogni interfaccia di rete deve essere assegnata a una subnet in una rete VPC univoca. Il tipo di stack dell'interfaccia di rete e il tipo di stack della subnet funzionano insieme come descritto in Tipi di stack e indirizzi IP.
Ogni istanza di computing riceve una route predefinita utilizzando l'opzione DHCP 121, come definito
dalla RFC 3442. La route predefinita
è associata a nic0
. Se non manualmente configurato in modo diverso, il traffico che lascia un'istanza per qualsiasi destinazione diversa da una subnet con collegamento diretto lascia l'istanza utilizzando la route predefinita su nic0
.
Sui sistemi Linux, puoi configurare regole e route personalizzate all'interno del sistema operativo guest
utilizzando il file /etc/iproute2/rt_tables
e i comandi ip rule
e ip route
. Per saperne di più, consulta la documentazione del sistema operativo guest. Per un
esempio, consulta il tutorial
Configurare il routing per un'interfaccia aggiuntiva.
Se non hai bisogno di più interfacce di rete, segui la procedura per creare e avviare un'istanza per creare istanze con la configurazione di rete predefinita.
Prima di iniziare
- Verifica che tutte le reti e le subnet richieste siano create prima di creare l'istanza di computing. Se devi creare reti o subnet, consulta Crea e gestisci reti VPC.
- Verifica che ogni rete disponga di regole firewall appropriate che consentano il trasferimento dei dati da e verso l'istanza con più interfacce. Se devi creare regole firewall, consulta Utilizzo delle regole firewall VPC.
-
Se connetti un'istanza a più reti utilizzando indirizzi IPv6, installa la versione
google-guest-agent
20220603.00 o successive. Per saperne di più, vedi Non riesco a connettermi all'indirizzo IPv6 di un'interfaccia secondaria. -
Se non l'hai ancora fatto, configura l'autenticazione.
L'autenticazione è
il processo di verifica dell'identità per poter accedere a Trusted Cloud by S3NS servizi e API.
Per eseguire codice o esempi da un ambiente di sviluppo locale, puoi autenticarti su
Compute Engine selezionando una delle seguenti opzioni:
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
-
Installa Google Cloud CLI, quindi accedi a gcloud CLI con la tua identità federata. Dopo aver eseguito l'accesso, inizializza Google Cloud CLI eseguendo il seguente comando:
gcloud init
- Set a default region and zone.
REST
Per utilizzare gli esempi di API REST in questa pagina in un ambiente di sviluppo locale, devi utilizzare le credenziali che fornisci a gcloud CLI.
Installa Google Cloud CLI, quindi accedi a gcloud CLI con la tua identità federata. Dopo aver eseguito l'accesso, inizializza Google Cloud CLI eseguendo il seguente comando:
gcloud init
Per saperne di più, consulta Autenticarsi per l'utilizzo di REST nella documentazione sull'autenticazione di Trusted Cloud .
Ruoli obbligatori
Per ottenere le autorizzazioni necessarie per creare un'istanza con una subnet specifica, chiedi all'amministratore di concederti il ruolo IAM Compute Instance Admin (v1) (
roles/compute.instanceAdmin.v1
) nel progetto. Per saperne di più sulla concessione dei ruoli, consulta Gestisci l'accesso a progetti, cartelle e organizzazioni.Questo ruolo predefinito contiene le autorizzazioni necessarie per creare un'istanza con una subnet specifica. Per vedere quali sono esattamente le autorizzazioni richieste, espandi la sezione Autorizzazioni obbligatorie:
Autorizzazioni obbligatorie
Per creare un'istanza con una subnet specifica sono necessarie le seguenti autorizzazioni:
-
compute.instances.create
sul progetto -
Per specificare una subnet per l'istanza:
compute.subnetworks.use
sul progetto o sulla subnet scelta -
Per assegnare un indirizzo IP esterno all'istanza quando utilizzi una rete VPC:
compute.subnetworks.useExternalIp
sul progetto o sulla subnet scelta
Potresti anche ottenere queste autorizzazioni con ruoli personalizzati o altri ruoli predefiniti.
Requisiti
Prima di creare un'istanza con più interfacce di rete, esamina i seguenti requisiti:
- Ad eccezione delle reti VPC create con un profilo di rete RDMA, si applica la seguente limitazione: se crei un'istanza con più interfacce di rete, ogni interfaccia deve connettersi a una rete VPC diversa. Le reti possono essere reti VPC autonome o reti VPC condivise.
- Ogni interfaccia di rete deve utilizzare un intervallo di indirizzi IP di subnet univoco.
- Per le istanze di Compute con più NIC in progetti autonomi, ogni interfaccia di rete deve utilizzare una subnet che si trova nello stesso progetto dell'istanza. Per le istanze nei progetti host o di servizio VPC condiviso, consulta VPC condiviso nella documentazione di Virtual Private Cloud. Le interfacce Private Service Connect consentono a un'istanza con più NIC di avere interfacce di rete in subnet in progetti diversi. Per saperne di più, vedi Informazioni sui collegamenti di rete.
Crea istanze VM con più interfacce di rete
La maggior parte delle istanze Compute Engine consente di configurare più vNIC durante la creazione dell'istanza.
- Per informazioni sul numero di interfacce di rete che puoi creare per un'istanza, consulta Numero massimo di interfacce di rete.
- Puoi anche configurare schede di interfaccia di rete dinamiche quando crei un'istanza.
Per informazioni su come creare un'istanza di calcolo con più interfacce di rete, vedi Crea istanze VM con più interfacce di rete.
Aggiungere interfacce di rete a un'istanza esistente
Puoi configurare le NIC virtuali (vNIC) per un'istanza solo quando la crei. Tuttavia, puoi aggiungere o rimuovere NIC dinamiche a un'istanza esistente e non devi riavviarla.
Le NIC dinamiche sono interfacce secondarie di una vNIC padre. Quando configuri una NIC dinamica, specifichi un ID VLAN utilizzato per taggare il traffico di rete per la NIC dinamica:
- L'ID VLAN di una NIC dinamica deve essere un numero intero compreso tra 2 e 255.
- L'ID VLAN di una NIC dinamica deve essere univoco all'interno di una vNIC padre. Tuttavia, le NIC dinamiche che appartengono a vNIC padre diverse possono utilizzare lo stesso ID VLAN.
Trusted Cloud by S3NS utilizza il seguente formato per il nome di una NIC dinamica:
PARENT_NIC_NUMBER.VLAN_ID
PARENT_NIC_NUMBER
è il nome della vNIC principale, ad esempionic0
.VLAN_ID
è il numero che hai specificato durante la configurazione della NIC dinamica. Un esempio di nome NIC dinamico ènic0.4
.Per informazioni su come aggiungere NIC dinamiche a un'istanza, consulta Aggiungere NIC dinamiche a un'istanza.
Passaggi successivi
- Scopri come utilizzare le connessioni SSH per connetterti all'istanza.
- Accedi alle VM utilizzando il DNS interno
- Crea un record PTR per un'istanza VM
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-08-18 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 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)"]] -