Par défaut, chaque instance de calcul possède au moins une interface réseau (vNIC) qui détermine le réseau de cloud privé virtuel utilisé par l'instance. Vous pouvez créer une instance avec plusieurs interfaces réseau. À l'exception des réseaux VPC créés avec un profil réseau RDMA, chaque interface réseau doit être attribuée à un sous-réseau dans un réseau VPC unique. Le type de pile de l'interface réseau et celui du sous-réseau fonctionnent ensemble, comme décrit dans Types de pile et adresses IP.
Chaque instance de calcul reçoit une route par défaut à l'aide de l'option DHCP 121, telle que définie par la RFC 3442. La route par défaut est associée à nic0
. Sauf configuration manuelle différente, tout trafic quittant une instance pour une destination autre qu'un sous-réseau directement connecté quittera l'instance en utilisant la route par défaut sur nic0
.
Sur les systèmes Linux, vous pouvez configurer des règles et des routes personnalisées dans l'OS invité à l'aide du fichier /etc/iproute2/rt_tables
et des commandes ip rule
et ip route
. Pour en savoir plus, consultez la documentation de l'OS invité. Pour obtenir un exemple, consultez le tutoriel Configurer le routage pour une interface supplémentaire.
Si vous n'avez pas besoin de plusieurs interfaces réseau, suivez la procédure décrite sur la page Créer et démarrer une instance pour créer des instances avec la configuration réseau par défaut.
Avant de commencer
- Vérifiez que tous les réseaux et sous-réseaux requis sont créés avant de créer l'instance de calcul. Si vous devez créer des réseaux ou des sous-réseaux, consultez Créer et gérer des réseaux VPC.
- Vérifiez que chaque réseau dispose de règles de pare-feu appropriées pour autoriser le transfert de données vers et depuis l'instance dotée de plusieurs interfaces. Si vous devez créer des règles de pare-feu, consultez la page Utiliser des règles de pare-feu VPC.
-
Si vous connectez une instance à plusieurs réseaux à l'aide d'adresses IPv6, installez la version 20220603.00 de
google-guest-agent
ou une version ultérieure. Pour en savoir plus, consultez Je ne parviens pas à me connecter à l'adresse IPv6 d'une interface secondaire. -
Si ce n'est pas déjà fait, configurez l'authentification.
L'authentification est le processus permettant de valider votre identité pour accéder aux services et aux API Trusted Cloud by S3NS .
Pour exécuter du code ou des exemples depuis un environnement de développement local, vous pouvez vous authentifier auprès de Compute Engine en sélectionnant l'une des options suivantes :
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
-
Installez la Google Cloud CLI, puis connectez-vous à la gcloud CLI avec votre identité fédérée. Après vous être connecté, initialisez Google Cloud CLI en exécutant la commande suivante :
gcloud init
- Set a default region and zone.
REST
Pour utiliser les exemples d'API REST de cette page dans un environnement de développement local, vous devez utiliser les identifiants que vous fournissez à gcloud CLI.
Installez la Google Cloud CLI, puis connectez-vous à la gcloud CLI avec votre identité fédérée. Après vous être connecté, initialisez Google Cloud CLI en exécutant la commande suivante :
gcloud init
Pour en savoir plus, consultez la section S'authentifier pour utiliser REST dans la documentation sur l'authentification Trusted Cloud .
Rôles requis
Pour obtenir les autorisations nécessaires pour créer une instance avec un sous-réseau spécifique, demandez à votre administrateur de vous accorder le rôle IAM Administrateur d'instances Compute (v1) (
roles/compute.instanceAdmin.v1
) sur le projet. Pour en savoir plus sur l'attribution de rôles, consultez la page Gérer l'accès aux projets, aux dossiers et aux organisations.Ce rôle prédéfini contient les autorisations requises pour créer une instance avec un sous-réseau spécifique. Pour connaître les autorisations exactes requises, développez la section Autorisations requises :
Autorisations requises
Les autorisations suivantes sont requises pour créer une instance avec un sous-réseau spécifique :
compute.instances.create
sur le projet-
Pour spécifier un sous-réseau pour votre instance :
compute.subnetworks.use
sur le projet ou sur le sous-réseau choisi -
Pour attribuer une adresse IP externe à l'instance quand vous utilisez un réseau VPC :
compute.subnetworks.useExternalIp
sur le projet ou sur le sous-réseau choisi
Vous pouvez également obtenir ces autorisations avec des rôles personnalisés ou d'autres rôles prédéfinis.
Conditions requises
Avant de créer une instance avec plusieurs interfaces réseau, consultez les exigences suivantes :
- À l'exception des réseaux VPC créés avec un profil réseau RDMA, la limitation suivante s'applique : si vous créez une instance avec plusieurs interfaces réseau, chaque interface doit se connecter à un réseau VPC différent. Les réseaux peuvent être des réseaux VPC autonomes ou des réseaux VPC partagés.
- Chaque interface réseau doit utiliser une plage d'adresses IP de sous-réseau unique.
- Pour les instances de calcul à plusieurs cartes d'interface réseau dans des projets autonomes, chaque interface réseau doit utiliser un sous-réseau situé dans le même projet que l'instance. Pour les instances dans les projets hôtes ou de service de VPC partagé, consultez VPC partagé dans la documentation Virtual Private Cloud. Les interfaces Private Service Connect permettent à une instance multi-NIC d'avoir des interfaces réseau dans des sous-réseaux de différents projets. Pour en savoir plus, consultez À propos des rattachements de réseau.
Créer des instances de VM avec plusieurs interfaces réseau
La plupart des instances Compute Engine vous permettent de configurer plusieurs cartes d'interface réseau virtuelles (vNIC) lorsque vous créez l'instance.
- Pour en savoir plus sur le nombre d'interfaces réseau que vous pouvez créer pour une instance, consultez Nombre maximal d'interfaces réseau.
- Vous pouvez également configurer des cartes d'interface réseau dynamiques lorsque vous créez une instance.
Pour savoir comment créer une instance de calcul avec plusieurs interfaces réseau, consultez Créer des instances de VM avec plusieurs interfaces réseau.
Ajouter des interfaces réseau à une instance existante
Vous ne pouvez configurer des cartes d'interface réseau virtuelles (vNIC) pour une instance que lorsque vous la créez. Toutefois, vous pouvez ajouter ou supprimer des cartes d'interface réseau dynamiques sur une instance existante sans avoir à la redémarrer.
Les interfaces réseau dynamiques sont des sous-interfaces d'une carte d'interface réseau virtuelle parente. Lorsque vous configurez une carte d'interface réseau dynamique, vous spécifiez un ID de VLAN qui est utilisé pour taguer le trafic réseau de la carte d'interface réseau dynamique :
- L'ID de VLAN d'une carte d'interface réseau dynamique doit être un nombre entier compris entre 2 et 255.
- L'ID de VLAN d'une carte d'interface réseau dynamique doit être unique dans une carte d'interface réseau virtuelle parente. Toutefois, les cartes d'interface réseau dynamiques appartenant à différentes cartes d'interface réseau virtuelles parentes peuvent utiliser le même ID de VLAN.
Trusted Cloud by S3NS utilise le format suivant pour le nom d'une carte d'interface réseau dynamique :
PARENT_NIC_NUMBER.VLAN_ID
PARENT_NIC_NUMBER
est le nom de la carte d'interface réseau virtuelle parente, par exemplenic0
.VLAN_ID
correspond au numéro que vous avez spécifié lors de la configuration de l'interface réseau dynamique. Exemple de nom de carte d'interface réseau dynamique :nic0.4
.Pour savoir comment ajouter des cartes d'interface réseau dynamiques à une instance, consultez Ajouter des cartes d'interface réseau dynamiques à une instance.
Étape suivante
- Découvrez comment utiliser les connexions SSH pour vous connecter à votre instance.
- Accéder aux VM à l'aide d'un DNS interne
- Créer un enregistrement PTR pour une instance de VM
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/08/18 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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)"]] -