デフォルトでは、すべてのコンピューティング インスタンスには、そのインスタンスが使用する Virtual Private Cloud ネットワークを決定するネットワーク インターフェース(vNIC)が少なくとも 1 つあります。複数のネットワーク インターフェースを持つインスタンスを作成できます。RDMA ネットワーク プロファイルを使用して作成された VPC ネットワークを除き、各ネットワーク インターフェースは一意の VPC ネットワーク内のサブネットに割り当てる必要があります。ネットワーク インターフェースのスタックタイプとサブネットのスタックタイプは、スタックタイプと IP アドレスで説明されているように連携します。
各コンピューティング インスタンスは、RFC 3442 で定義されている DHCP オプション 121 を使用してデフォルト ルートを受け取ります。デフォルト ルートは nic0
に関連付けられています。手動で別途構成しない限り、直接接続されたサブネット以外の宛先に送信されるトラフィックはすべて、nic0
のデフォルト ルートを使用して送出されます。
Linux システムでは、/etc/iproute2/rt_tables
ファイルと ip rule
および ip route
コマンドを使用して、ゲスト OS 内でカスタムルールとカスタムルートを構成できます。詳細については、ゲスト OS のドキュメントをご覧ください。例については、追加のインターフェースのルーティングを構成するチュートリアルをご覧ください。
複数のネットワーク インターフェースが不要な場合は、インスタンスの作成と起動の手順に沿って、デフォルトのネットワーク構成でインスタンスを作成してください。
始める前に
- コンピューティング インスタンスを作成する前に、必要なネットワークとサブネットがすべて作成されていることを確認します。ネットワークまたはサブネットを作成する必要がある場合は、VPC ネットワークの作成と管理をご覧ください。
- 各ネットワークに、複数のインターフェースを持つインスタンス間のデータ転送を許可する適切なファイアウォール ルールがあることを確認します。ファイアウォール ルールを作成する必要がある場合は、VPC ファイアウォール ルールを使用するをご覧ください。
-
IPv6 アドレスを使用してインスタンスを複数のネットワークに接続する場合は、
google-guest-agent
バージョン 20220603.00 以降をインストールします。詳細については、セカンダリ インターフェースの IPv6 アドレスに接続できないをご覧ください。 -
まだ設定していない場合は、認証を設定します。認証とは、 Trusted Cloud by S3NS サービスと API にアクセスするために ID を確認するプロセスです。ローカル開発環境からコードまたはサンプルを実行するには、次のいずれかのオプションを選択して Compute Engine に対する認証を行います。
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
-
Google Cloud CLI をインストールし、 連携 ID を使用して gcloud CLI にログインします。 ログイン後、次のコマンドを実行して Google Cloud CLI を初期化します。
gcloud init
- Set a default region and zone.
REST
このページの REST API サンプルをローカル開発環境で使用するには、gcloud CLI に指定した認証情報を使用します。
Google Cloud CLI をインストールし、 連携 ID を使用して gcloud CLI にログインします。 ログイン後、次のコマンドを実行して Google Cloud CLI を初期化します。
gcloud init
詳細については、 Trusted Cloud 認証ドキュメントの REST を使用して認証するをご覧ください。
必要なロール
特定のサブネットを持つインスタンスの作成に必要な権限を取得するには、プロジェクトに対する Compute インスタンス管理者(v1)(
roles/compute.instanceAdmin.v1
)IAM ロールを付与するよう管理者に依頼してください。ロールの付与については、プロジェクト、フォルダ、組織に対するアクセス権の管理をご覧ください。この事前定義ロールには、特定のサブネットを持つインスタンスの作成に必要な権限が含まれています。必要とされる正確な権限については、「必要な権限」セクションを開いてご確認ください。
必要な権限
特定のサブネットを持つインスタンスを作成するには、次の権限が必要です。
- プロジェクトに対する
compute.instances.create
-
インスタンスのサブネットを指定する: プロジェクトまたは選択したサブネットに対する
compute.subnetworks.use
-
VPC ネットワークの使用時にインスタンスに外部 IP アドレスを割り当てる: プロジェクトまたは選択したサブネットに対する
compute.subnetworks.useExternalIp
カスタムロールや他の事前定義ロールを使用して、これらの権限を取得することもできます。
要件
複数のネットワーク インターフェースを持つインスタンスを作成する前に、次の要件を確認します。
- RDMA ネットワーク プロファイルを使用して作成された VPC ネットワークを除き、次の制限が適用されます。複数のネットワーク インターフェースを持つインスタンスを作成する場合は、各インターフェースを別々の VPC ネットワークに接続する必要があります。接続先は、スタンドアロンの VPC ネットワークまたは共有 VPC ネットワークにすることができます。
- 各ネットワーク インターフェースでは、重複しないサブネット IP アドレス範囲を使用する必要があります。
- スタンドアロン プロジェクト内のマルチ NIC コンピューティング インスタンスの場合、各ネットワーク インターフェースでは、インスタンスと同じプロジェクトにあるサブネットを使用する必要があります。共有 VPC ホスト プロジェクトまたはサービス プロジェクト内のインスタンスの場合は、Virtual Private Cloud のドキュメントにある共有 VPC をご覧ください。マルチ NIC インスタンスで Private Service Connect インターフェースを使用すると、ネットワーク インターフェースで別のプロジェクト内のサブネットを使用できます。詳細については、ネットワーク アタッチメントについてをご覧ください。
複数のネットワーク インターフェースを持つ VM インスタンスを作成する
ほとんどの Compute Engine インスタンスでは、インスタンスの作成時に複数の vNIC を構成できます。
- インスタンスに作成できるネットワーク インターフェースの数については、ネットワーク インターフェースの最大数をご覧ください。
- インスタンスの作成時に Dynamic NIC を構成することもできます。
複数のネットワーク インターフェースを持つコンピューティング インスタンスの作成方法については、複数のネットワーク インターフェースを持つ VM インスタンスを作成するをご覧ください。
既存のインスタンスにネットワーク インターフェースを追加する
インスタンスの仮想 NIC(vNIC)を構成できるのは、インスタンスの作成時のみです。ただし、既存のインスタンスに Dynamic NIC を追加または削除することはできます。その際、インスタンスを再起動する必要はありません。
Dynamic NIC は、親 vNIC のサブインターフェースです。Dynamic NIC を構成するときに、VLAN ID を指定します。この ID は、Dynamic NIC のネットワーク トラフィックのタグ付けに使用されます。
- Dynamic NIC の VLAN ID は、2~255 の整数にする必要があります。
- Dynamic NIC の VLAN ID は、親 vNIC 内で一意である必要があります。ただし、異なる親 vNIC に属する Dynamic NIC では同じ VLAN ID を使用できます。
Trusted Cloud by S3NS では、Dynamic NIC の名前として次の形式が使用されます。
PARENT_NIC_NUMBER.VLAN_ID
PARENT_NIC_NUMBER
は、親 vNIC の名前です(例:nic0
)。VLAN_ID
は、Dynamic NIC の構成時に指定した番号です。たとえば、Dynamic NIC の名前はnic0.4
のようになります。インスタンスに Dynamic NIC を追加する方法については、インスタンスに Dynamic NIC を追加するをご覧ください。
次のステップ
- SSH 接続を使用してインスタンスに接続する方法を学習する
- 内部 DNS を使用して VM にアクセスする
- VM インスタンスの PTR レコードを作成する
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-18 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 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)"]] -