Mengonfigurasi netmask instance yang lebih besar untuk semua instance di subnet

Halaman ini menjelaskan cara mengonfigurasi semua instance Compute Engine di subnet dengan netmask yang lebih besar dari netmask default. Untuk menggunakan konfigurasi ini, Anda membuat subnet dan mengonfigurasi setelan Resolve subnet mask (--resolve-subnet-mask). Saat Anda menghubungkan instance komputasi ke subnet, instance tersebut dikonfigurasi dengan netmask yang berukuran sama dengan netmask subnet, bukan /32. Untuk mengetahui informasi selengkapnya tentang netmask instance komputasi, lihat Netmask instance komputasi.

Sebelum memulai

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. Pelanggan baru juga mendapatkan kredit gratis senilai $300 untuk menjalankan, menguji, dan men-deploy workload.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  4. Verify that billing is enabled for your Google Cloud project.

  5. Enable the Compute Engine API.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the API

  6. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  7. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  8. Verify that billing is enabled for your Google Cloud project.

  9. Enable the Compute Engine API.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the API

Peran yang diperlukan

Untuk mendapatkan izin yang diperlukan guna membuat subnet, minta administrator untuk memberi Anda peran IAM Admin Jaringan Compute (role/compute.networkAdmin) di project Anda. Untuk mengetahui informasi selengkapnya tentang pemberian peran, lihat Mengelola akses ke project, folder, dan organisasi.

Anda mungkin juga bisa mendapatkan izin yang diperlukan melalui peran khusus atau peran bawaan lainnya.

Membuat subnet untuk mengonfigurasi netmask instance yang lebih besar

Konsol

  1. Di konsol Google Cloud , buka halaman VPC networks.

    Buka VPC networks

  2. Pilih jaringan VPC.

  3. Klik tab Subnets.

  4. Klik Add subnet.

  5. Untuk Name, masukkan nama subnet.

  6. Untuk Region, pilih region.

  7. Untuk Purpose, pilih None.

  8. Untuk IP stack type, pilih IPv4 (single stack).

  9. Untuk Primary IPv4 range, masukkan rentang alamat IPv4 yang valid.

  10. Jika Anda ingin menambahkan rentang IPv4 sekunder, lakukan hal berikut:

    1. Untuk Subnet range name, masukkan nama untuk rentang IPv4 sekunder.
    2. Untuk Secondary IPv4 range, masukkan rentang alamat IPv4 yang valid.
  11. Di Resolve subnet mask, pilih salah satu opsi berikut:

    • All ranges
    • Primary range only
  12. Klik Add.

gcloud

gcloud compute networks subnets create SUBNET_NAME \
    --network=NETWORK_NAME \
    --range=IP_RANGE \
    --region=REGION \
    --resolve-subnet-mask=ARP_RANGES

Ganti kode berikut:

  • SUBNET_NAME: nama untuk subnet.
  • NETWORK_NAME: jaringan tempat subnet akan dibuat.
  • IP_RANGE: rentang alamat IPv4 utama untuk subnet.
  • REGION: region untuk subnet.
  • ARP_RANGES: rentang yang ingin Anda terima balasan ARP-nya. Nilai yang valid adalah ARP_PRIMARY_RANGE dan ARP_ALL_RANGES.

Membuat instance komputasi di subnet

Buat instance komputasi yang terhubung ke subnet. Untuk mengetahui informasi selengkapnya tentang cara membuat instance, lihat Membuat instance di subnet tertentu.

gcloud CLI

gcloud compute instances create INSTANCE_NAME \
    --zone=ZONE \
    --subnet=SUBNET_NAME

Ganti kode berikut:

  • INSTANCE_NAME: nama untuk instance Anda.
  • ZONE: zona tempat instance akan dibuat.
  • SUBNET_NAME: nama subnet yang akan dihubungkan ke instance.

Memverifikasi konfigurasi

Setelah membuat instance komputasi, Anda dapat memverifikasi bahwa server DHCP mengonfigurasi netmask yang benar pada instance, dan instance menerima balasan ARP. Anda dapat memverifikasi balasan ARP hanya dengan menggunakan satu instance karena Google Cloud selalu mengirim balasan untuk alamat IP dalam rentang subnet.

Langkah-langkah berikut menunjukkan cara memverifikasi konfigurasi pada instance Linux.

  1. Hubungkan ke instance Anda menggunakan SSH.
  2. Periksa konfigurasi antarmuka jaringan untuk memverifikasi bahwa netmask cocok dengan netmask subnet (bukan /32).

    ip addr show
    

    Dalam output, cari baris inet untuk antarmuka jaringan Anda, misalnya, ens4.

  3. Verifikasi bahwa instance dapat menerima balasan ARP untuk alamat IP lain di subnet. Anda dapat menggunakan perintah ping untuk memicu permintaan ARP. Anda dapat memilih alamat IP yang tidak digunakan—Google Cloud mengirim balasan ARP meskipun tidak ada balasan untuk permintaan ping.

    ping -c 3 OTHER_IP_ADDRESS_IN_SUBNET
    

    Ganti OTHER_IP_ADDRESS_IN_SUBNET dengan alamat IP dari subnet yang sama. Alamat IP ini tidak harus digunakan.

  4. Periksa tabel ARP untuk melihat alamat MAC yang terkait dengan alamat IP lainnya.

    ip neighbor
    

    Output akan menampilkan alamat MAC dari alamat IP lainnya.