Secara default, setiap instance komputasi memiliki setidaknya satu antarmuka jaringan (vNIC) yang menentukan jaringan Virtual Private Cloud yang digunakan instance. Anda dapat membuat instance dengan beberapa antarmuka jaringan. Kecuali untuk jaringan VPC yang dibuat dengan profil jaringan RDMA, setiap antarmuka jaringan harus ditetapkan ke subnet di jaringan VPC yang unik. Jenis stack antarmuka jaringan dan jenis stack subnet bekerja bersama seperti yang dijelaskan dalam Jenis stack dan alamat IP
Setiap instance komputasi menerima rute default menggunakan Opsi DHCP 121, seperti yang ditentukan
oleh RFC 3442. Rute default
dikaitkan dengan nic0
. Kecuali jika dikonfigurasi secara manual, traffic yang keluar dari instance untuk tujuan apa pun selain subnet yang terhubung langsung akan keluar dari instance menggunakan rute default pada nic0
.
Di sistem Linux, Anda dapat mengonfigurasi aturan dan rute kustom dalam OS tamu
menggunakan file /etc/iproute2/rt_tables
dan perintah ip rule
serta ip route
. Untuk mengetahui informasi selengkapnya, baca dokumentasi OS tamu. Sebagai
contoh, lihat tutorial
Mengonfigurasi perutean untuk antarmuka tambahan.
Jika Anda tidak memerlukan beberapa antarmuka jaringan, ikuti prosedur untuk membuat dan memulai instance guna membuat instance dengan konfigurasi jaringan default.
Sebelum memulai
- Pastikan semua jaringan dan subnet yang diperlukan telah dibuat sebelum Anda membuat instance komputasi. Jika Anda perlu membuat jaringan atau subnet, lihat Membuat dan mengelola jaringan VPC.
- Pastikan setiap jaringan memiliki aturan firewall yang sesuai yang memungkinkan transfer data ke dan dari instance yang memiliki beberapa antarmuka. Jika Anda perlu membuat aturan firewall, lihat Menggunakan aturan firewall VPC.
-
Jika Anda
menghubungkan
instance ke beberapa jaringan dengan menggunakan alamat IPv6,
instal
google-guest-agent
versi 20220603.00 atau yang lebih baru. Untuk mengetahui informasi selengkapnya, lihat Saya tidak dapat terhubung ke alamat IPv6 antarmuka sekunder. -
Jika Anda belum melakukannya, siapkan autentikasi.
Autentikasi adalah
proses yang digunakan untuk memverifikasi identitas Anda untuk mengakses Trusted Cloud by S3NS layanan dan API.
Untuk menjalankan kode atau sampel dari lingkungan pengembangan lokal, Anda dapat melakukan autentikasi ke
Compute Engine dengan memilih salah satu opsi berikut:
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
-
Instal Google Cloud CLI, lalu login ke gcloud CLI dengan identitas gabungan Anda. Setelah login, lakukan inisialisasi Google Cloud CLI dengan menjalankan perintah berikut:
gcloud init
- Set a default region and zone.
REST
Untuk menggunakan contoh REST API di halaman ini dalam lingkungan pengembangan lokal, Anda menggunakan kredensial yang Anda berikan ke gcloud CLI.
Instal Google Cloud CLI, lalu login ke gcloud CLI dengan identitas gabungan Anda. Setelah login, lakukan inisialisasi Google Cloud CLI dengan menjalankan perintah berikut:
gcloud init
Untuk mengetahui informasi selengkapnya, lihat Melakukan autentikasi untuk menggunakan REST dalam dokumentasi autentikasi Trusted Cloud .
Peran yang diperlukan
Untuk mendapatkan izin yang diperlukan untuk membuat instance dengan subnet tertentu, minta administrator untuk memberi Anda peran IAM Compute Instance Admin (v1) (
roles/compute.instanceAdmin.v1
) di project. Untuk mengetahui informasi selengkapnya tentang cara memberikan peran, lihat Mengelola akses ke project, folder, dan organisasi.Peran bawaan ini berisi izin yang diperlukan untuk membuat instance dengan subnet tertentu. Untuk melihat izin yang benar-benar diperlukan, luaskan bagian Izin yang diperlukan:
Izin yang diperlukan
Izin berikut diperlukan untuk membuat instance dengan subnet tertentu:
-
compute.instances.create
di project -
Untuk menentukan subnet untuk instance Anda:
compute.subnetworks.use
pada project atau pada subnet yang dipilih -
Untuk menetapkan alamat IP eksternal ke instance saat menggunakan jaringan VPC:
compute.subnetworks.useExternalIp
di project atau di subnet yang dipilih
Anda mungkin juga bisa mendapatkan izin ini dengan peran khusus atau peran bawaan lainnya.
Persyaratan
Sebelum membuat instance dengan beberapa antarmuka jaringan, tinjau persyaratan berikut:
- Kecuali untuk jaringan VPC yang dibuat dengan profil jaringan RDMA, batasan berikut berlaku: Jika Anda membuat instance dengan beberapa antarmuka jaringan, setiap antarmuka harus terhubung ke jaringan VPC yang berbeda. Jaringan dapat berupa jaringan VPC mandiri atau jaringan VPC Bersama.
- Setiap antarmuka jaringan harus menggunakan rentang alamat IP subnet yang unik.
- Untuk instance komputasi multi-NIC dalam project mandiri, setiap antarmuka jaringan harus menggunakan subnet yang berada dalam project yang sama dengan instance. Untuk instance di project host atau layanan VPC Bersama, lihat VPC Bersama dalam dokumentasi Virtual Private Cloud. Antarmuka Private Service Connect menyediakan cara bagi instance multi-NIC untuk memiliki antarmuka jaringan di subnet dalam project yang berbeda. Untuk mengetahui informasi selengkapnya, lihat Tentang lampiran jaringan.
Membuat instance VM dengan beberapa antarmuka jaringan
Sebagian besar instance Compute Engine memungkinkan Anda mengonfigurasi beberapa vNIC saat membuat instance.
- Untuk mengetahui informasi tentang jumlah antarmuka jaringan yang dapat Anda buat untuk instance, lihat Jumlah maksimum antarmuka jaringan.
- Anda juga dapat mengonfigurasi NIC Dinamis saat membuat instance.
Untuk mengetahui informasi tentang cara membuat instance komputasi dengan beberapa antarmuka jaringan, lihat Membuat instance VM dengan beberapa antarmuka jaringan.
Menambahkan antarmuka jaringan ke instance yang ada
Anda hanya dapat mengonfigurasi NIC virtual (vNIC) untuk instance saat membuat instance. Namun, Anda dapat menambahkan atau menghapus NIC Dinamis ke instance yang ada, dan Anda tidak perlu memulai ulang instance.
NIC dinamis adalah subantarmuka vNIC induk. Saat mengonfigurasi NIC Dinamis, Anda menentukan ID VLAN yang digunakan untuk memberi tag pada traffic jaringan untuk NIC Dinamis:
- ID VLAN NIC Dinamis harus berupa bilangan bulat dari 2 hingga 255.
- ID VLAN NIC Dinamis harus unik dalam vNIC induk. Namun, NIC Dinamis yang termasuk dalam vNIC induk yang berbeda dapat menggunakan ID VLAN yang sama.
Trusted Cloud by S3NS menggunakan format berikut untuk nama NIC Dinamis:
PARENT_NIC_NUMBER.VLAN_ID
PARENT_NIC_NUMBER
adalah nama vNIC induk, misalnyanic0
.VLAN_ID
adalah nomor yang Anda tentukan saat mengonfigurasi NIC Dinamis. Contoh nama NIC Dinamis adalahnic0.4
.Untuk mengetahui informasi tentang cara menambahkan NIC Dinamis ke instance, lihat Menambahkan NIC Dinamis ke instance.
Apa langkah selanjutnya?
- Pelajari cara menggunakan koneksi SSH untuk terhubung ke instance Anda.
- Mengakses VM menggunakan DNS internal
- Membuat data PTR untuk instance VM
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-08-18 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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)"]] -