Integrasi Keamanan Jaringan menggunakan model produsen-konsumen untuk memeriksa dan memantau data. Fitur ini menggunakan integrasi dalam band dengan teknologi pencegatan paket untuk menyisipkan perangkat jaringan pihak ketiga ke dalam alur traffic jaringan dan melakukan pemeriksaan paket mendalam.
Tutorial ini menjelaskan cara membuat dan mengonfigurasi resource produsen dan konsumen untuk menyiapkan integrasi dalam band.
Tujuan
Tutorial ini menunjukkan cara menyelesaikan tugas-tugas berikut dalam project:
- Buat jaringan VPC kustom dengan subnet untuk produsen dan konsumen dalam project yang sama.
- Untuk produsen, buat dan konfigurasi resource produsen, seperti Load Balancer Jaringan passthrough internal, layanan pencegatan, dan resource deployment pencegatan.
- Untuk konsumen, buat dan konfigurasi instance virtual machine (VM) klien dan server, resource endpoint konsumen, dan kebijakan firewall untuk mencegat traffic klien-server.
- Uji koneksi dan verifikasi bahwa paket traffic jaringan dicegat oleh resource endpoint konsumen dan diperiksa oleh resource pencegat produsen.
Sebelum memulai
- Login ke akun Google Cloud Anda. Jika Anda baru menggunakan Google Cloud, buat akun untuk mengevaluasi performa produk kami dalam skenario dunia nyata. Pelanggan baru juga mendapatkan kredit gratis senilai $300 untuk menjalankan, menguji, dan men-deploy workload.
-
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
- Aktifkan Compute Engine API untuk project Anda.
- Aktifkan Network Security API di Google Cloud project yang ingin Anda gunakan untuk penagihan.
- Pastikan Anda memiliki
peran Admin Jaringan
Compute
(
roles/compute.networkAdmin) yang diberikan di tingkat project dan peran Admin Profil Keamanan (roles/networksecurity.securityProfileAdmin) yang diberikan di tingkat organisasi. - Jika Anda lebih suka bekerja dari command line, instal
Google Cloud CLI. Untuk mengetahui informasi konseptual dan penginstalan tentang
alat ini, lihat Ringkasan gcloud CLI.
Catatan: Jika Anda belum pernah menjalankan Google Cloud CLI sebelumnya, jalankan
gcloud initterlebih dahulu untuk menginisialisasi direktori gcloud CLI Anda. Dapatkan ID project Anda. Anda memerlukannya untuk membuat resource endpoint dan intersep.
Jika menggunakan gcloud CLI, Anda dapat mengganti
PROJECT_IDdi sini atau nanti dalam perintah masing-masing.Dapatkan ID organisasi Anda. Anda memerlukannya untuk membuat resource tingkat organisasi, seperti profil keamanan dan grup profil keamanan.
Jika menggunakan gcloud CLI, Anda dapat mengganti
ORG_IDdi sini atau nanti dalam perintah masing-masing.
Membuat resource produser
Di bagian ini, Anda akan membuat resource berikut untuk produser:
- Jaringan VPC kustom dengan subnet.
- Grup instance tidak terkelola dengan instance VM yang menjalankan server echo Generic Network Virtualization Encapsulation (GENEVE).
- Load Balancer Jaringan passthrough internal dengan layanan backend dan aturan penerusan.
- Aturan firewall untuk mengizinkan Google Cloud health check.
- Grup deployment pencegatan dan deployment pencegatan.
Membuat jaringan VPC kustom
Di bagian ini, Anda akan membuat jaringan VPC dengan subnet.
Konsol
Di konsol Google Cloud , buka halaman VPC networks.
Klik Create VPC network.
Untuk Name, masukkan
producer-network.Untuk Description, masukkan
Producer VPC network.Di bagian Subnets, lakukan tindakan berikut:
- Untuk Subnet creation mode, pilih Custom.
- Di bagian New subnet, masukkan informasi berikut:
- Nama:
producer-subnet - Region:
us-west1 - IP stack type: IPv4 (single-stack)
- Rentang IPv4:
10.10.0.0/16
- Nama:
- Klik Done.
Klik Create.
Buka Google Cloud CLI dan jalankan perintah berikut untuk meningkatkan unit transmisi maksimum (MTU) jaringan VPC.
gcloud compute networks update producer-network \ --mtu=1768Dalam perintah, Anda menentukan MTU sebesar 1768 byte, yang merupakan jumlah MTU default jaringan VPC (1460 byte) dan overhead enkapsulasi GENEVE Integrasi Keamanan Jaringan (308 byte).
gcloud
Buat jaringan VPC.
gcloud compute networks create producer-network \ --subnet-mode=custom \ --mtu=1768 \ --description="Producer VPC network"Dalam perintah, Anda menentukan unit transmisi maksimum (MTU) sebesar 1768 byte, yang merupakan jumlah MTU default jaringan VPC (1460 byte) dan overhead enkapsulasi GENEVE Integrasi Keamanan Jaringan (308 byte).
Di jaringan VPC, buat subnet.
gcloud compute networks subnets create producer-subnet \ --network=producer-network \ --region=us-west1 \ --range=10.10.0.0/16
Buat grup instance tidak terkelola
Di bagian ini, Anda akan membuat grup instance yang tidak dikelola.
Konsol
Di konsol Google Cloud , buka halaman Instance groups.
Klik Create instance group.
Klik New unmanaged instance group.
Untuk Name, masukkan
producer-instance-group.Di bagian Location, pilih
us-west1untuk Region, dan pilihus-west1-buntuk Zone.Untuk Network, pilih
producer-network.Untuk Subnetwork, pilih
producer-subnet.Klik Create.
gcloud
gcloud compute instance-groups unmanaged create producer-instance-group \
--zone=us-west1-b
Mengonfigurasi komponen load balancer
Di bagian ini, Anda akan membuat komponen untuk Load Balancer Jaringan passthrough internal, termasuk layanan backend dan aturan penerusan.
Konsol
Mulai konfigurasi
Di konsol Google Cloud , buka halaman Load balancing.
- Klik Create load balancer.
- Untuk Type of load balancer, pilih Network Load Balancer (TCP/UDP/SSL), lalu klik Next.
- Untuk Proxy or passthrough, pilih Passthrough load balancer, lalu klik Next.
- Untuk Public facing or internal, pilih Internal, lalu klik Next.
- Klik Configure.
Konfigurasi dasar
Di halaman Buat Load Balancer Jaringan passthrough internal, masukkan informasi berikut:
- Nama load balancer:
producer-ilb - Region:
us-west1 - Network:
producer-network
Mengonfigurasi backend
- Klik Backend configuration.
- Untuk Protocol, pilih
UDP. - Dari daftar Health check, pilih Create a health check, masukkan
informasi berikut, lalu klik Create.
- Nama:
producer-health-check - Cakupan: Regional
- Port:
80 - Protokol proxy:
NONE
- Nama:
- Di bagian New Backend pada Backends, pilih IP stack type sebagai IPv4 (single-stack).
- Di Instance group, pilih grup instance
producer-instance-group, lalu klik Done. - Pastikan terdapat tanda centang biru di samping Backend configuration sebelum melanjutkan.
Mengonfigurasi frontend
Di bagian New Frontend IP and port, lakukan tindakan berikut:
- Untuk Name, masukkan
producer-ilb-fr. - Untuk Subnetwork, pilih
producer-subnet. - Untuk Ports, pilih Single, lalu di Port number,
masukkan
6081. - Pastikan terdapat tanda centang biru di samping Frontend configuration sebelum melanjutkan.
Meninjau konfigurasi
- Klik Review and finalize.
- Tinjau setelan konfigurasi load balancer Anda.
- Klik Create.
gcloud
Buat health check regional.
gcloud compute health-checks create tcp producer-health-check \ --region=us-west1 \ --port=80Buat layanan backend.
gcloud compute backend-services create producer-backend-service \ --protocol=UDP \ --region=us-west1 \ --health-checks=producer-health-check \ --health-checks-region=us-west1 \ --load-balancing-scheme=INTERNALBuat aturan penerusan untuk layanan backend.
gcloud compute forwarding-rules create producer-ilb-fr \ --backend-service=producer-backend-service \ --region=us-west1 \ --network=producer-network \ --subnet=producer-subnet \ --ip-protocol=UDP \ --load-balancing-scheme=INTERNAL \ --ports=6081
Buat instance VM dan tambahkan ke grup instance
Di bagian ini, Anda akan membuat instance VM dengan skrip startup yang menyiapkan server echo untuk paket yang dienkapsulasi GENEVE.
Sebelum membuat instance VM, dapatkan alamat IP aturan penerusan Load Balancer Jaringan passthrough internal dan gateway subnet. Anda memerlukan alamat IP untuk skrip startup.
Konsol
Mendapatkan alamat IP Load Balancer Jaringan passthrough internal
Di konsol Google Cloud , buka halaman Load balancing.
Klik load balancer
producer-ilb.Di bagian Frontend, catat alamat IP aturan penerusan dari kolom IP:ports.
Mendapatkan alamat IP gateway subnet
Di konsol Google Cloud , buka halaman VPC networks.
Klik jaringan VPC
producer-network.Klik tab Subnet.
Di bagian Subnet, catat alamat IP gateway dari kolom Gateway.
Buat instance VM
Di konsol Google Cloud , buka halaman VM instances.
- Klik Create instance.
- Untuk Name, masukkan
producer-instance. - Untuk Region, pilih
us-west1. - Untuk Zone, pilih
us-west1-b. Klik Networking dan konfigurasi kolom berikut:
Di bagian Network interfaces, klik
defaultdan edit antarmuka jaringan.- Network:
producer-network - Subnet:
producer-subnet - External IPv4 address: None
- Network:
Klik Advanced dan masukkan skrip berikut di Startup script:
#!/bin/bash # Enable IP forwarding. echo 1 > /proc/sys/net/ipv4/ip_forward # Log incoming packets from the gateway IP and the GENEVE 6081 # port. iptables -t nat -A PREROUTING -p udp -s GATEWAY_IP/32 --dport 6081 -j LOG --log-prefix="[NSI INTERCEPT] " # Apply DNAT (Destination NAT) on incoming packets from the gateway IP # and the GENEVE 6081 port. # Set the destination IP to the gateway IP so the packet is rerouted # back to the sender. iptables -t nat -A PREROUTING -p udp -s GATEWAY_IP/32 --dport 6081 -j DNAT --to-destination GATEWAY_IP # Apply SNAT (Source NAT) on outgoing packets that have the GENEVE 6081 # port and source IP that equals the gateway IP. # Set the source IP to the internal load balancer IP which # effectively swaps the IPs of the original packet. iptables -t nat -A POSTROUTING -p udp -s GATEWAY_IP/32 --dport 6081 -j SNAT --to-source LOAD_BALANCER_IP # Spin up a simple server for health checks on port 80. nohup python3 -u -m http.server 80 &
Ganti kode berikut:
GATEWAY_IP: alamat IP gateway subnet.LOAD_BALANCER_IP: alamat IP aturan penerusan load balancer.
Klik Create.
Tambahkan instance VM ke grup instance
Di konsol Google Cloud , buka halaman Instance groups.
Klik
producer-instance-group.Klik Edit.
Di bagian VM instances, dari daftar Select VMs, pilih
producer-instanceVM.Klik Simpan.
gcloud
Dapatkan alamat IP aturan penerusan load balancer.
ILB_IP=$(gcloud compute forwarding-rules describe producer-ilb-fr \ --region=us-west1 \ --format="get(IPAddress)")Dapatkan alamat IP gateway subnet.
GW_IP=$(gcloud compute networks subnets describe producer-subnet \ --region=us-west1 \ --format="get(gatewayAddress)")Buat instance VM.
gcloud compute instances create producer-instance \ --image-project=debian-cloud \ --image-family=debian-11 \ --machine-type=e2-micro \ --zone=us-west1-b \ --network-interface="subnet=producer-subnet,no-address" \ --metadata=startup-script='#!/bin/bash # Enable IP forwarding. echo 1 > /proc/sys/net/ipv4/ip_forward # Log incoming packets from the gateway IP and the GENEVE 6081 port. iptables -t nat -A PREROUTING -p udp -s '"$GW_IP"'/32 --dport 6081 -j LOG --log-prefix="[NSI INTERCEPT] " # Apply DNAT (Destination NAT) on incoming packets from the gateway # IP and the GENEVE 6081 port. # Set the destination IP to the gateway IP so the packet is rerouted # back to the sender. iptables -t nat -A PREROUTING -p udp -s '"$GW_IP"'/32 --dport 6081 -j DNAT --to-destination '"$GW_IP"' # Apply SNAT (Source NAT) on outgoing packets that have the GENEVE # 6081 port and source IP that equals the gateway IP. # Set the source IP to the internal load balancer IP which # effectively swaps the IPs of the original packet. iptables -t nat -A POSTROUTING -p udp -s '"$GW_IP"'/32 --dport 6081 -j SNAT --to-source '"$ILB_IP"' # Spin up a simple server for health checks on port 80. nohup python3 -u -m http.server 80 &'Tambahkan instance VM ke grup instance.
gcloud compute instance-groups unmanaged add-instances producer-instance-group \ --instances=producer-instance \ --zone=us-west1-bTambahkan grup instance ke layanan backend.
gcloud compute backend-services add-backend producer-backend-service \ --region=us-west1 \ --instance-group=producer-instance-group \ --instance-group-zone=us-west1-b
Membuat kebijakan firewall dan menambahkan aturan firewall
Di bagian ini, Anda akan membuat kebijakan firewall dan menambahkan aturan firewall untuk mengizinkan koneksi UDP, Google Cloud pemeriksaan health check, dan koneksi SSH ke instance VM produser melalui Identity-Aware Proxy (IAP).
Konsol
Di konsol Google Cloud , buka halaman Firewall policies.
Klik Create firewall policy.
Di kolom Name, masukkan
producer-firewall-policy.Untuk Deployment scope, pilih Global, lalu klik Continue.
Buat aturan berikut untuk kebijakan Anda.
Izinkan koneksi UDP dengan port GENEVE dari alamat IP gateway VPC
- Klik Create firewall rule dan konfigurasikan kolom berikut:
- Prioritas:
100 - Direction of traffic: Ingress
- Tindakan terhadap kecocokan: Izinkan
- Source filters > IP ranges:
GATEWAY_IP - Protocol and ports: Pilih Specified protocol and ports, centang kotak UDP, lalu tentukan
6081di Ports.
- Prioritas:
- Klik Create.
Ganti
GATEWAY_IPdengan alamat IP gateway subnet.Mengizinkan Google Cloud health check
- Klik Create firewall rule dan konfigurasikan kolom berikut:
- Prioritas:
101 - Direction of traffic: Ingress
- Tindakan terhadap kecocokan: Izinkan
- Rentang IP:
35.191.0.0/16dan130.211.0.0/22 - Protokol dan port: Pilih Specified protocol and ports, centang kotak TCP, lalu tentukan
80di Ports.
- Prioritas:
- Klik Create.
Izinkan koneksi SSH ke instance VM produsen melalui Identity-Aware Proxy
- Klik Create firewall rule dan konfigurasikan kolom berikut:
- Prioritas:
102 - Direction of traffic: Ingress
- Tindakan terhadap kecocokan: Izinkan
- Rentang IP:
35.235.240.0/20 - Protokol dan port: Pilih Specified protocol and ports, centang kotak TCP, lalu tentukan
22di Ports.
- Prioritas:
- Klik Create.
- Klik Create firewall rule dan konfigurasikan kolom berikut:
Untuk mengaitkan kebijakan dengan jaringan, klik Lanjutkan, lalu klik Kaitkan.
Centang kotak
producer-network.Klik Lanjutkan.
Klik Create.
gcloud
Buat kebijakan firewall jaringan global.
gcloud compute network-firewall-policies create producer-firewall-policy \ --globalKaitkan kebijakan firewall dengan jaringan produsen.
gcloud compute network-firewall-policies associations create \ --name=producer-firewall-policy-assoc \ --firewall-policy=producer-firewall-policy \ --global-firewall-policy \ --network=producer-networkBuat aturan firewall untuk mengizinkan koneksi UDP dengan port GENEVE dari alamat IP gateway VPC.
gcloud compute network-firewall-policies rules create 100 \ --firewall-policy=producer-firewall-policy \ --global-firewall-policy \ --action=allow \ --direction=INGRESS \ --layer4-configs=udp:6081 \ --src-ip-ranges=$GW_IP/32Buat aturan firewall untuk mengizinkan Google Cloud health check.
gcloud compute network-firewall-policies rules create 101 \ --firewall-policy=producer-firewall-policy \ --global-firewall-policy \ --action=allow \ --direction=INGRESS \ --layer4-configs=tcp:80 \ --src-ip-ranges=35.191.0.0/16,130.211.0.0/22Buat aturan firewall untuk mengizinkan koneksi SSH ke instance VM produsen melalui Identity-Aware Proxy.
gcloud compute network-firewall-policies rules create 102 \ --firewall-policy=producer-firewall-policy \ --global-firewall-policy \ --action=allow \ --direction=INGRESS \ --layer4-configs=tcp:22 \ --src-ip-ranges=35.235.240.0/20
Membuat resource pencegatan produsen
Di bagian ini, Anda akan membuat grup deployment pencegat dan deployment pencegat.
Konsol
Di konsol Google Cloud , buka halaman Deployment groups.
Klik Create deployment group.
Untuk Name, masukkan
producer-deployment-group.Untuk Network, pilih
producer-network.Untuk Purpose, pilih NSI in-band.
Di bagian Intercept deployments, klik Create intercept deployment, tentukan kolom berikut, lalu klik Create:
- Name:
producer-deployment. - Region:
us-west1. - Zona:
us-west1-b. - Load balancer internal:
producer-ilb.
- Name:
Klik Create.
gcloud
Buat grup deployment pencegat.
gcloud network-security intercept-deployment-groups create producer-deployment-group \ --location=global \ --network=projects/PROJECT_ID/global/networks/producer-network \ --no-asyncGanti
PROJECT_IDdengan ID project Anda.Buat deployment pencegatan.
gcloud network-security intercept-deployments create producer-deployment \ --location=us-west1-b \ --forwarding-rule=producer-ilb-fr \ --forwarding-rule-location=us-west1 \ --intercept-deployment-group=projects/PROJECT_ID/locations/global/interceptDeploymentGroups/producer-deployment-group \ --no-asyncGanti
PROJECT_IDdengan ID project Anda.
Membuat resource konsumen
Di bagian ini, Anda akan membuat resource berikut untuk konsumen:
- Jaringan VPC kustom dengan subnet.
- Server dan VM klien.
- Kebijakan dan aturan firewall untuk mencegat traffic.
- Grup endpoint pencegat dan asosiasi grup endpoint pencegat.
- Profil keamanan dan grup profil keamanan.
Membuat jaringan VPC kustom
Di bagian ini, Anda akan membuat jaringan VPC dengan subnet.
Konsol
Di konsol Google Cloud , buka halaman VPC networks.
Klik Create VPC network.
Untuk Name, masukkan
consumer-network.Untuk Description, masukkan
Consumer VPC network.Di bagian Subnets, lakukan tindakan berikut:
- Setel Subnet creation mode ke Custom.
- Di bagian New subnet, masukkan informasi berikut:
- Nama:
consumer-subnet - Region:
us-west1 - IP stack type: IPv4 (single-stack)
- Rentang IPv4:
10.10.0.0/16
- Nama:
- Klik Done.
Klik Create.
gcloud
Buat jaringan VPC konsumen.
gcloud compute networks create consumer-network \ --subnet-mode=custom \ --description="Consumer VPC network"Di jaringan VPC, buat subnet.
gcloud compute networks subnets create consumer-subnet \ --network=consumer-network \ --region=us-west1 \ --range=10.10.0.0/16
Membuat VM server dan klien
Di bagian ini, Anda akan membuat server dan VM klien.
Konsol
Membuat VM server
Di konsol Google Cloud , buka halaman VM instances.
Klik Create instance.
Setel Nama ke
consumer-server-vm.Setel Wilayah ke
us-west1.Setel Zona ke
us-west1-b.Setel Machine type ke e2-micro.
Klik Networking dan konfigurasi kolom berikut:
Di bagian Network interfaces, klik
defaultdan edit antarmuka jaringan:- Network:
consumer-network - Subnet:
consumer-subnet - External IPv4 address: None
- Network:
Klik Advanced dan masukkan skrip berikut di Startup script:
echo success > /tmp/connection_test && nohup python3 -u -m http.server --directory /tmp 8000
Klik Create.
Membuat VM klien
Di konsol Google Cloud , buka halaman VM instances.
Klik Create instance.
Setel Nama ke
consumer-client-vm.Setel Wilayah ke
us-west1.Setel Zona ke
us-west1-b.Setel Machine type ke e2-micro.
Klik Networking dan konfigurasi kolom berikut:
Di bagian Network interfaces, klik
defaultdan edit antarmuka jaringan:- Network:
consumer-network - Subnet:
consumer-subnet - External IPv4 address: None
- Network:
Klik Create.
gcloud
Buat VM server.
gcloud compute instances create consumer-server-vm \ --image-project=debian-cloud \ --image-family=debian-11 \ --machine-type=e2-micro \ --zone=us-west1-b \ --network-interface="subnet=consumer-subnet,no-address" \ --metadata=startup-script="echo success > /tmp/connection_test && nohup python3 -u -m http.server --directory /tmp 8000"Buat VM klien.
gcloud compute instances create consumer-client-vm \ --image-project=debian-cloud \ --image-family=debian-11 \ --machine-type=e2-micro \ --zone=us-west1-b \ --network-interface="subnet=consumer-subnet,no-address"
Buat kebijakan firewall untuk mengizinkan akses SSH
Di bagian ini, Anda akan membuat kebijakan firewall dan menambahkan aturan firewall untuk mengizinkan akses SSH ke VM konsumen.
Konsol
Di konsol Google Cloud , buka halaman Firewall policies.
Klik Create firewall policy.
Di kolom Name, masukkan
consumer-firewall-policy.Untuk Deployment scope, pilih Global, lalu klik Continue.
Klik Create firewall rule, konfigurasikan kolom berikut, lalu klik Create:
- Prioritas:
100 - Direction of traffic: Ingress
- Tindakan terhadap kecocokan: Izinkan
- Source filters > IP ranges:
35.235.240.0/20 - Protokol dan port: Pilih Specified protocol and ports, centang kotak TCP, lalu tentukan
22di Ports.
Rentang IPv4
35.235.240.0/20berisi semua alamat IP yang digunakan Identity-Aware Proxy untuk penerusan TCP. Untuk mengetahui informasi selengkapnya, lihat Menyiapkan project untuk TCP forwarding.- Prioritas:
Untuk mengaitkan kebijakan dengan jaringan, klik Lanjutkan, lalu klik Kaitkan.
Centang kotak
consumer-network.Klik Lanjutkan.
Klik Create.
gcloud
Buat kebijakan firewall jaringan global.
gcloud compute network-firewall-policies create consumer-firewall-policy \ --globalKaitkan kebijakan firewall dengan jaringan konsumen.
gcloud compute network-firewall-policies associations create \ --name=consumer-firewall-policy-assoc \ --firewall-policy=consumer-firewall-policy \ --global-firewall-policy \ --network=consumer-networkBuat aturan izinkan SSH untuk mengizinkan koneksi SSH ke instance VM klien melalui Identity-Aware Proxy.
gcloud compute network-firewall-policies rules create 101 \ --firewall-policy=consumer-firewall-policy \ --global-firewall-policy \ --action=allow \ --direction=INGRESS \ --layer4-configs=tcp:22 \ --src-ip-ranges=35.235.240.0/20Rentang IPv4
35.235.240.0/20berisi semua alamat IP yang digunakan Identity-Aware Proxy (IAP) untuk penerusan TCP. Untuk mengetahui informasi selengkapnya, lihat Menyiapkan project untuk penerusan TCP.
Buat grup endpoint konsumen
Di bagian ini, Anda akan membuat grup endpoint pencegat dan asosiasi grup endpoint pencegat.
Konsol
Di konsol Google Cloud , buka halaman Endpoint groups.
Klik Create endpoint group.
Untuk Name, masukkan
consumer-endpoint-group.Untuk Deployment group, dari menu Select project, pilih Select current project.
Untuk Intercept deployment group, pilih
producer-deployment-group.Klik Lanjutkan.
Klik Add endpoint group association.
Untuk Project, pilih project saat ini.
Untuk Network, pilih
consumer-network.Klik Create.
gcloud
Buat grup endpoint pencegat.
gcloud network-security intercept-endpoint-groups create consumer-endpoint-group \ --location=global \ --intercept-deployment-group=projects/PROJECT_ID/locations/global/interceptDeploymentGroups/producer-deployment-group \ --no-asyncGanti
PROJECT_IDdengan ID project Anda.Buat asosiasi grup endpoint pencegat.
gcloud network-security intercept-endpoint-group-associations create consumer-endpoint-group-association \ --location=global \ --intercept-endpoint-group=projects/PROJECT_ID/locations/global/interceptEndpointGroups/consumer-endpoint-group \ --network=consumer-network \ --no-asyncGanti
PROJECT_IDdengan ID project Anda.
Membuat profil keamanan dan grup profil keamanan
Buat grup profil keamanan dan profil keamanan kustom untuk mencegat traffic.
Konsol
Membuat profil keamanan
Di konsol Google Cloud , buka halaman Security profiles.
Dari pemilih project, pilih organisasi Anda.
Di tab Security profiles, klik Create profile.
Untuk Name, masukkan
consumer-security-profile.Untuk Security profile purpose, pilih NSI in-band.
Untuk Project, pilih project saat ini.
Untuk Intercept endpoint group, pilih
consumer-endpoint-group.Klik Create.
Membuat grup profil keamanan
Di konsol Google Cloud , buka halaman Security profile groups.
Dari pemilih project, pilih organisasi Anda.
Di tab Grup profil keamanan, klik Buat grup profil.
Untuk Name, masukkan
consumer-security-profile-group.Untuk Tujuan grup profil keamanan, pilih NSI in-band.
Untuk Custom intercept profile, pilih
consumer-security-profile.Klik Create.
gcloud
Buat profil keamanan pencegatan.
gcloud network-security security-profiles custom-intercept create consumer-security-profile \ --location=global \ --organization=ORG_ID \ --intercept-endpoint-group=projects/PROJECT_ID/locations/global/interceptEndpointGroups/consumer-endpoint-group \ --no-asyncGanti kode berikut:
ORG_ID: ID organisasi Anda. Profil keamanan adalah resource tingkat organisasi. Untuk membuatnya, Anda memerlukan peran Admin Profil Keamanan (networksecurity.securityProfileAdmin) di tingkat organisasi.PROJECT_ID: ID project Anda.
Buat grup profil keamanan pencegatan.
gcloud network-security security-profile-groups create consumer-security-profile-group \ --location=global \ --organization=ORG_ID \ --custom-intercept-profile=consumer-security-profile \ --billing-project=PROJECT_ID \ --no-asyncGanti kode berikut:
ORG_ID: ID organisasi Anda. Grup profil keamanan adalah resource tingkat organisasi. Untuk membuatnya, Anda memerlukan peran Admin Profil Keamanan (networksecurity.securityProfileAdmin) di tingkat organisasi.PROJECT_ID: ID project Anda.
Membuat kebijakan firewall untuk mencegat traffic
Di bagian ini, Anda akan membuat kebijakan firewall dan aturan firewall untuk mencegat traffic.
Konsol
Di konsol Google Cloud , buka halaman Firewall policies.
Klik
consumer-firewall-policy.Klik Create firewall rule dan konfigurasikan kolom berikut:
- Prioritas:
100 - Direction of traffic: Ingress
- Tindakan terhadap kecocokan: Lanjutkan ke inspeksi L7
- Tujuan: NSI dalam band
- Grup profil keamanan:
consumer-security-profile-group - Rentang IP:
10.10.0.0/16 - Protokol dan port: Pilih Specified protocol and ports, centang kotak TCP, lalu tentukan
8000di Ports.
- Prioritas:
Klik Create.
gcloud
Tambahkan aturan firewall untuk mencegat traffic di port TCP 8000 di VM server.
gcloud compute network-firewall-policies rules create 100 \ --firewall-policy=consumer-firewall-policy \ --global-firewall-policy \ --action=apply_security_profile_group \ --security-profile-group=organizations/ORG_ID/locations/global/securityProfileGroups/consumer-security-profile-group \ --direction=INGRESS \ --layer4-configs=tcp:8000 \ --src-ip-ranges=10.10.0.0/16Ganti
ORG_IDdengan ID organisasi Anda.
Menguji koneksi
Di bagian ini, Anda akan mengirimkan beberapa traffic jaringan dari instance VM klien konsumen ke instance VM server konsumen, lalu memeriksa log instance VM produsen untuk memverifikasi pencegatan.
Jalankan perintah berikut untuk terhubung ke instance VM klien konsumen melalui SSH, dan kirim permintaan ke instance VM server konsumen.
gcloud compute ssh consumer-client-vm \ --tunnel-through-iap \ --zone=us-west1-b \ --command="curl -m 3 -s http://consumer-server-vm:8000/connection_test || echo fail"Anda melihat pesan
successsaat menjalankan perintah sebelumnya. Menunjukkan bahwa traffic dikirim dari klien ke server.Jalankan perintah berikut untuk memeriksa log instance VM produsen.
gcloud compute ssh producer-instance \ --tunnel-through-iap \ --zone=us-west1-b \ --command="cat /var/log/syslog | grep 'NSI INTERCEPT'"Anda akan melihat pesan yang mirip dengan
[NSI INTERCEPT] IN=ens4 OUT= MAC=xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx SRC=10.10.0.1 DST=10.10.0.2 LEN=136 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=UDP SPT=45554 DPT=6081 LEN=116. Hal ini menunjukkan bahwa traffic klien-server dicegat oleh instance VM produsen.
Pembersihan
Agar tidak perlu membayar biaya pada akun Google Cloud Anda untuk resource yang digunakan dalam tutorial ini, hapus project yang berisi resource tersebut, atau simpan project dan hapus setiap resource.
Menghapus resource konsumen
Batalkan pengaitan kebijakan firewall dari jaringan konsumen dan hapus kebijakan firewall.
Konsol
Di konsol Google Cloud , buka halaman Firewall policies.
Klik kebijakan
consumer-firewall-policy.Klik tab Pengaitan.
Pilih kotak centang pengaitan
consumer-network.Klik Hapus atribusi.
Klik Hapus.
Di bagian atas halaman, klik Hapus.
Klik Delete lagi untuk mengonfirmasi.
gcloud
Hapus atribusi.
gcloud compute network-firewall-policies associations delete \ --name=consumer-firewall-policy-assoc \ --firewall-policy=consumer-firewall-policy \ --global-firewall-policyHapus kebijakan firewall.
gcloud compute network-firewall-policies delete consumer-firewall-policy \ --global
Hapus grup profil keamanan.
Konsol
Di konsol Google Cloud , buka halaman Security profiles.
Dari pemilih project, pilih organisasi Anda.
Di tab Grup profil keamanan, pilih grup profil keamanan
consumer-security-profile-group, lalu klik Hapus.Klik Delete lagi untuk mengonfirmasi.
gcloud
gcloud network-security security-profile-groups delete consumer-security-profile-group \ --location=global \ --organization=ORG_ID \ --billing-project=PROJECT_ID \ --quietGanti kode berikut:
ORG_ID: ID organisasi AndaPROJECT_ID: ID project Anda
Hapus profil keamanan.
Konsol
Di konsol Google Cloud , buka halaman Security profiles.
Dari pemilih project, pilih organisasi Anda.
Di tab Security profiles, pilih profil keamanan
consumer-security-profile, lalu klik Delete.Klik Delete lagi untuk mengonfirmasi.
gcloud
gcloud network-security security-profiles custom-intercept delete consumer-security-profile \ --location=global \ --organization=ORG_ID \ --billing-project=PROJECT_ID \ --quietGanti kode berikut:
ORG_ID: ID organisasi AndaPROJECT_ID: ID project Anda
Hapus asosiasi grup endpoint pencegat.
Konsol
Di konsol Google Cloud , buka halaman Endpoint groups.
Klik
consumer-endpoint-group.Pilih atribusi
consumer-network, lalu klik Hapus.Klik Delete lagi untuk mengonfirmasi.
gcloud
gcloud network-security intercept-endpoint-group-associations delete consumer-endpoint-group-association \ --location=global \ --no-asyncHapus grup endpoint pencegat.
Konsol
Di konsol Google Cloud , buka halaman Endpoint groups.
Pilih
consumer-endpoint-group, lalu klik Hapus.Klik Delete lagi untuk mengonfirmasi.
gcloud
gcloud network-security intercept-endpoint-groups delete consumer-endpoint-group \ --location=global \ --no-asyncHapus VM server dan klien.
Konsol
Di konsol Google Cloud , buka halaman VM instances.
Pilih kotak centang
consumer-client-vmdanconsumer-server-vm, lalu klik Hapus.Klik Delete lagi untuk mengonfirmasi.
gcloud
Hapus VM klien.
gcloud compute instances delete consumer-client-vm \ --zone=us-west1-b \ --quietHapus VM server.
gcloud compute instances delete consumer-server-vm \ --zone=us-west1-b \ --quiet
Hapus jaringan dan subnet konsumen.
Konsol
Di konsol Google Cloud , buka halaman VPC networks.
Klik
consumer-network.Di tab Subnets, centang kotak
consumer-subnet, lalu klik Delete.Klik Delete lagi untuk mengonfirmasi.
Klik Delete VPC network.
Di kolom teks, masukkan
consumer-network, lalu klik Hapus.
gcloud
Hapus subnet.
gcloud compute networks subnets delete consumer-subnet \ --region=us-west1 \ --quietHapus jaringan VPC.
gcloud compute networks delete consumer-network \ --quiet
Menghapus resource produser
Batalkan pengaitan kebijakan firewall dari jaringan produsen dan hapus kebijakan firewall.
Konsol
Di konsol Google Cloud , buka halaman Firewall policies.
Klik kebijakan
producer-firewall-policy.Klik tab Pengaitan.
Pilih kotak centang pengaitan
producer-network.Klik Hapus atribusi.
Klik Hapus.
Di bagian atas halaman, klik Hapus.
Klik Delete lagi untuk mengonfirmasi.
gcloud
Hapus atribusi.
gcloud compute network-firewall-policies associations delete \ --name=producer-firewall-policy-assoc \ --firewall-policy=producer-firewall-policy \ --global-firewall-policyHapus kebijakan firewall.
gcloud compute network-firewall-policies delete producer-firewall-policy \ --global
Hapus deployment intersep dan grup deployment intersep.
Konsol
Di konsol Google Cloud , buka halaman Deployment groups.
Klik
producer-deployment-group.Hapus
producer-deployment.- Centang kotak
producer-deployment, lalu klik Hapus. - Klik Delete lagi untuk mengonfirmasi.
- Centang kotak
Klik tombol Delete di bagian atas halaman.
Klik Delete lagi untuk mengonfirmasi.
gcloud
Hapus deployment pencegat.
gcloud network-security intercept-deployments delete producer-deployment \ --location=us-west1-b \ --no-asyncHapus grup deployment pencegat.
gcloud network-security intercept-deployment-groups delete producer-deployment-group \ --location=global \ --no-async
Hapus resource load balancer.
Konsol
Di konsol Google Cloud , buka halaman Load balancing.
Centang kotak
producer-ilb.Klik tombol Delete di bagian atas halaman.
Centang kotak
producer-health-check, lalu klik Delete load balancer and the selected resources.
gcloud
Hapus aturan penerusan.
gcloud compute forwarding-rules delete producer-ilb-fr \ --region=us-west1 \ --quietHapus layanan backend.
gcloud compute backend-services delete producer-backend-service \ --region=us-west1 \ --quietHapus health check.
gcloud compute health-checks delete producer-health-check \ --region=us-west1 \ --quiet
Hapus instance VM produser.
Konsol
Di konsol Google Cloud , buka halaman VM instances.
Centang kotak
producer-instance, lalu klik Hapus.Klik Delete lagi untuk mengonfirmasi.
gcloud
gcloud compute instances delete producer-instance \ --zone=us-west1-b \ --quietHapus grup instance.
Konsol
Di konsol Google Cloud , buka halaman Instance groups.
Centang kotak
producer-instance-group.Klik Hapus.
Di jendela konfirmasi, klik Delete.
gcloud
gcloud compute instance-groups unmanaged delete producer-instance-group \ --zone=us-west1-b \ --quietHapus jaringan dan subnet produser.
Konsol
Di konsol Google Cloud , buka halaman VPC networks.
Klik
producer-network.Di tab Subnets, centang kotak
producer-subnetlalu klik Delete.Klik Delete lagi untuk mengonfirmasi.
Klik Delete VPC network.
Di kolom teks, masukkan
producer-network, lalu klik Hapus.
gcloud
Hapus subnet.
gcloud compute networks subnets delete producer-subnet \ --region=us-west1 \ --quietHapus jaringan.
gcloud compute networks delete producer-network \ --quiet
Langkah berikutnya
- Ringkasan grup deployment pencegatan
- Ringkasan deployment pencegatan
- Ringkasan grup dan asosiasi endpoint pencegat
- Ringkasan profil keamanan
- Ringkasan grup profil keamanan
- Pelajari arsitektur referensi, diagram, dan praktik terbaik tentang Google Cloud. Lihat Cloud Architecture Center kami.