1. บทนำ
ภาพรวม
ในแล็บนี้ ผู้ใช้จะได้สำรวจวิธีใช้ Network Connectivity Center (NCC) เพื่อสร้างการเชื่อมต่อในองค์กรที่ปรับขนาดได้ผ่านการรองรับ VPC Spokes และการแลกเปลี่ยนเส้นทางแบบไดนามิก เมื่อผู้ใช้กำหนด VPC เป็น VPC Spoke จะทำให้เชื่อมต่อ VPC กับเครือข่าย VPC หลายเครือข่ายเข้าด้วยกันผ่าน NCC Hub ได้ หากต้องการสร้างการเชื่อมต่อเครือข่ายกับเครือข่ายในองค์กรของผู้ใช้ ผู้ใช้สามารถแนบ NIC เสมือนของอุปกรณ์เราเตอร์ อุโมงค์ HA_VPN หรือไฟล์แนบ VLAN ของ Interconnect ไปยังฮับ NCC เดียวกันกับ Spoke VPC ของ NCC ได้
ทรัพยากรฮับมีโมเดลการจัดการการเชื่อมต่อจากส่วนกลางเพื่อเชื่อมต่อ Spoke
สิ่งที่คุณจะสร้าง
ใน Codelab นี้ คุณจะได้สร้างโทโพโลยีฮับและสโป๊กเชิงตรรกะด้วยฮับ NCC ซึ่งจะใช้การเชื่อมต่อแบบไฮบริดระหว่างเครือข่ายภายในองค์กรกับ VPC ของภาระงาน

สิ่งที่คุณจะได้เรียนรู้
- ความแตกต่างระหว่าง VPC สำหรับภาระงานกับ VPC สำหรับการกำหนดเส้นทาง
- การผสานรวม NCC ของเครือข่ายย่อย VPC และเครือข่ายย่อยแบบไฮบริด
สิ่งที่คุณต้องมี
- ความรู้เกี่ยวกับเครือข่าย VPC ของ GCP
- ความรู้เกี่ยวกับ Cloud Router และการกำหนดเส้นทาง BGP
- โปรเจ็กต์ Google Cloud
- ตรวจสอบโควต้า: เครือข่ายและขอเครือข่ายเพิ่มเติมหากจำเป็น ภาพหน้าจอด้านล่าง

วัตถุประสงค์
- ตั้งค่าสภาพแวดล้อม GCP
- กำหนดค่า Network Connectivity Center ด้วย VPC เป็นเครือข่ายย่อย
- กำหนดค่า Network Connectivity Center ด้วยอุโมงค์ข้อมูล VPN ความพร้อมใช้งานสูง เป็น Spoke แบบไฮบริด
- ตรวจสอบเส้นทางข้อมูล
- สำรวจฟีเจอร์ความพร้อมในการให้บริการของ NCC
- ล้างทรัพยากรที่ใช้แล้ว
ก่อนเริ่มต้น
คอนโซล Google Cloud และ Cloud Shell
หากต้องการโต้ตอบกับ GCP เราจะใช้ทั้งคอนโซล Google Cloud และ Cloud Shell ตลอดทั้ง Lab นี้
โปรเจ็กต์ NCC Hub คอนโซล Google Cloud
คุณเข้าถึง Cloud Console ได้ที่ https://console.cloud.google.com
ตั้งค่ารายการต่อไปนี้ใน Google Cloud เพื่อให้กำหนดค่า Network Connectivity Center ได้ง่ายขึ้น
ในคอนโซล Google Cloud ในหน้าตัวเลือกโปรเจ็กต์ ให้เลือกหรือสร้างโปรเจ็กต์ Google Cloud
เปิด Cloud Shell Codelab นี้ใช้ $variables เพื่อช่วยในการติดตั้งใช้งานการกำหนดค่า gcloud ใน Cloud Shell
gcloud auth list
gcloud config list project
gcloud config set project [YOUR-PROJECT-NAME]
projectname=[YOUR-PROJECT-NAME]
echo $projectname
region="us-central1"
zone="us-central1-a"
บทบาท IAM
NCC กำหนดให้ใช้บทบาท IAM เพื่อเข้าถึง API บางรายการ อย่าลืมกำหนดค่าผู้ใช้ด้วยบทบาท IAM ของ NCC ตามที่จำเป็น
บทบาท/คำอธิบาย | สิทธิ์ |
networkconnectivity.networkAdmin - อนุญาตให้ผู้ดูแลระบบเครือข่ายจัดการฮับและสโป๊ก | networkconnectivity.hubs.networkconnectivity.spokes. |
networkconnectivity.networkSpokeManager - อนุญาตให้เพิ่มและจัดการ Spoke ในฮับ ใช้ใน VPC ที่แชร์ซึ่งโปรเจ็กต์โฮสต์เป็นเจ้าของฮับ แต่ผู้ดูแลระบบอื่นๆ ในโปรเจ็กต์อื่นๆ สามารถเพิ่ม Spoke สำหรับการเชื่อมต่อของตนเองไปยังฮับได้ | networkconnectivity.spokes.** |
networkconnectivity.networkUsernetworkconnectivity.networkViewer - อนุญาตให้ผู้ใช้เครือข่ายดูแอตทริบิวต์ต่างๆ ของฮับและสโป๊ก | networkconnectivity.hubs.getnetworkconnectivity.hubs.listnetworkconnectivity.spokes.getnetworkconnectivity.spokes.listnetworkconnectivity.spokes.aggregatedList |
2. ตั้งค่าสภาพแวดล้อมเครือข่าย
ภาพรวม
ในส่วนนี้ เราจะทำให้เครือข่าย VPC และกฎไฟร์วอลล์ทั้ง 3 รายการใช้งานได้ในโปรเจ็กต์เดียว แผนภาพเชิงตรรกะแสดงสภาพแวดล้อมเครือข่ายที่จะตั้งค่าในขั้นตอนนี้ สำหรับ Codelab นี้ เราจะใช้ VPC เพื่อจำลองเครือข่ายในองค์กร

แนวคิดหลัก 1
VPC ทั่วโลกของ Google Cloud ให้การเชื่อมต่อเส้นทางข้อมูลระหว่างภูมิภาค GCP มากกว่า 44 แห่ง Cloud Router ซึ่งเป็นบริการระดับภูมิภาคจะประกาศเครือข่ายย่อยแบบไดนามิกและเผยแพร่เส้นทางที่เรียนรู้ในภูมิภาคที่มีการกำหนดค่าเราเตอร์หรือทั่วทั้งเครือข่าย VPC สิ่งที่กำหนดให้ Cloud Router กระจายเส้นทางในระดับภูมิภาคหรือระดับโลกขึ้นอยู่กับผู้ใช้ที่กำหนดโหมดการกำหนดเส้นทางแบบไดนามิก ได้แก่ ระดับภูมิภาคหรือระดับโลก
ในส่วนนี้ เราจะเริ่มต้นด้วยการกำหนดค่า VPC แต่ละรายการด้วยโหมดการกำหนดเส้นทางระดับภูมิภาค สำหรับ Codelab ที่เหลือ
- "VPC การกำหนดเส้นทาง" ระบุ VPC ที่ไม่ได้กำหนดค่าเป็นเครือข่ายย่อยของ NCC VPC
- "VPC สำหรับภาระงาน" ระบุ VPC ที่กำหนดค่าเป็น Spoke ของ NCC
สร้าง VPC ของภาระงานและซับเน็ต
เครือข่าย VPC มีซับเน็ตที่คุณจะติดตั้ง GCE VM เพื่อตรวจสอบเส้นทางข้อมูล
vpc_spoke_network_name="workload-vpc"
vpc_spoke_subnet_name="workload-subnet"
vpc_spoke_subnet_ip_range="10.0.1.0/24"
vpc_spoke_name="workload-vpc-spoke"
region="us-central1"
zone="us-central1-a"
gcloud compute networks create "${vpc_spoke_network_name}" \
--subnet-mode=custom
gcloud compute networks subnets create "${vpc_spoke_subnet_name}" \
--network="${vpc_spoke_network_name}" \
--range="${vpc_spoke_subnet_ip_range}" \
--region="${region}"
สร้าง VPC การกำหนดเส้นทางและซับเน็ต
NCC รองรับช่วงซับเน็ต IPv4 ที่ถูกต้องทั้งหมด ยกเว้นที่อยู่ IP สาธารณะที่ใช้แบบส่วนตัว
routing_vpc_network_name="routing-vpc"
routing_vpc_subnet_name="routing-vpc-subnet"
routing_vpc_subnet_range="10.0.2.0/24"
gcloud compute networks create "${routing_vpc_network_name}" \
--subnet-mode=custom
gcloud compute networks subnets create "${routing_vpc_subnet_name}" \
--region="${region}" \
--network="${routing_vpc_network_name}" \
--range="${routing_vpc_subnet_range}"
สร้าง VPC ในองค์กรและซับเน็ต
NCC รองรับช่วงซับเน็ต IPv4 ที่ถูกต้องทั้งหมด ยกเว้นที่อยู่ IP สาธารณะที่ใช้แบบส่วนตัว
on_prem_network_name="on-prem-net-vpc"
on_prem_subnet_name="on-prem-subnet"
on_prem_subnet_range="10.0.3.0/24"
gcloud compute networks create "${on_prem_network_name}" \
--subnet-mode=custom
gcloud compute networks subnets create "${on_prem_subnet_name}" \
--region="${region}" \
--network="${on_prem_network_name}" \
--range="${on_prem_subnet_range}"
กำหนดค่ากฎไฟร์วอลล์ VPC ของภาระงาน
workload_vpc_firewall_name="workload-protocol-fw-vpc"
workload_port_firewall_name="workload-port-firewall-vpc"
gcloud compute firewall-rules create "${workload_vpc_firewall_name}" \
--network=${vpc_spoke_network_name} \
--allow="tcp,udp,icmp"
gcloud compute firewall-rules create "${workload_port_firewall_name}" \
--network=${vpc_spoke_network_name} \
--allow="tcp:22,tcp:3389,tcp:11180,icmp"
กำหนดค่า VPC การกำหนดเส้นทางและกฎไฟร์วอลล์ VPC
routing_vpc_fw_name="routing-vpc-protocol-fw"
routing_vpc_port_fw_name="routing-vpc--port-fw"
gcloud compute firewall-rules create "${routing_vpc_fw_name}" \
--network=${routing_vpc_network_name} \
--allow="tcp,udp,icmp"
gcloud compute firewall-rules create "${routing_vpc_port_fw_name}" \
--network=${routing_vpc_network_name} \
--allow="tcp:22,tcp:3389,tcp:11180,icmp"
กำหนดค่ากฎไฟร์วอลล์ VPC และ VPC ภายในองค์กร
prem_protocol_fw_name="onprem-vpc-protocol-firewall"
prem_port_firewall_name="onprem-vpc-port-firewall-prem"
gcloud compute firewall-rules create "${prem_protocol_fw_name}" \
--network=${on_prem_network_name} \
--allow="tcp,udp,icmp"
gcloud compute firewall-rules create "${prem_port_firewall_name}" \
--network=${on_prem_network_name} \
--allow="tcp:22,tcp:3389,tcp:11180,icmp"
กำหนดค่า GCE VM ในแต่ละ VPC
คุณจะต้องมีสิทธิ์เข้าถึงอินเทอร์เน็ตชั่วคราวเพื่อติดตั้งแพ็กเกจใน "vm1-vpc1-ncc"
สร้างเครื่องเสมือน 3 เครื่อง โดยแต่ละเครื่องจะกำหนดให้กับ VPC ที่สร้างไว้ก่อนหน้านี้
gcloud compute instances create vm1-vpc-workload \
--zone us-central1-a \
--subnet="${vpc_spoke_subnet_name}" \
--metadata=startup-script='#!/bin/bash
apt-get update
apt-get install apache2 -y
apt-get install tcpdump -y
service apache2 restart
echo "
<h3>Web Server: www-vm1</h3>" | tee /var/www/html/index.html'
gcloud compute instances create vm2-vpc-routing \
--zone us-central1-a \
--subnet="${routing_vpc_subnet_name}" \
--no-address
gcloud compute instances create vm3-onprem \
--zone us-central1-a \
--subnet="${on_prem_subnet_name}" \
--no-address
3. ตั้งค่าการเชื่อมต่อแบบไฮบริด
ในส่วนนี้ เราจะกำหนดค่าอุโมงค์ VPN ความพร้อมใช้งานสูง เพื่อเชื่อมต่อเครือข่าย VPC ภายในองค์กรและเครือข่าย VPC การกำหนดเส้นทางเข้าด้วยกัน

กำหนดค่า Cloud Router ด้วย BGP ใน VPC การกำหนดเส้นทาง
routing_vpc_router_name="routing-vpc-cr"
routing_vpc_router_asn=64525
gcloud compute routers create "${routing_vpc_router_name}" \
--region="${region}" \
--network="${routing_vpc_network_name}" \
--asn="${routing_vpc_router_asn}"
กำหนดค่า Cloud Router ด้วย BGP ใน VPC ภายในองค์กร
on_prem_router_name="on-prem-router"
on_prem_router_asn=64526
gcloud compute routers create "${on_prem_router_name}" \
--region="${region}" \
--network="${on_prem_network_name}" \
--asn="${on_prem_router_asn}"
กำหนดค่าเกตเวย์ VPN ใน VPC การกำหนดเส้นทาง
routing_vpn_gateway_name="routing-vpc-vpn-gateway"
gcloud compute vpn-gateways create "${routing_vpn_gateway_name}" \
--region="${region}" \
--network="${routing_vpc_network_name}"
กำหนดค่าเกตเวย์ VPN ใน VPC ภายในองค์กร
on_prem_gateway_name="on-prem-vpn-gateway"
gcloud compute vpn-gateways create "${on_prem_gateway_name}" \
--region="${region}" \
--network="${on_prem_network_name}"
กำหนดค่าอุโมงค์ข้อมูล VPN ใน VPC การกำหนดเส้นทางและ VPC ภายในองค์กร
secret_key=$(openssl rand -base64 24)
routing_vpc_tunnel_name="routing-vpc-tunnel"
on_prem_tunnel_name="on-prem-tunnel"
gcloud compute vpn-tunnels create "${routing_vpc_tunnel_name}" \
--vpn-gateway="${routing_vpn_gateway_name}" \
--peer-gcp-gateway="${on_prem_gateway_name}" \
--router="${routing_vpc_router_name}" \
--region="${region}" \
--interface=0 \
--shared-secret="${secret_key}"
gcloud compute vpn-tunnels create "${on_prem_tunnel_name}" \
--vpn-gateway="${on_prem_gateway_name}" \
--peer-gcp-gateway="${routing_vpn_gateway_name}" \
--router="${on_prem_router_name}" \
--region="${region}" \
--interface=0 \
--shared-secret="${secret_key}"
สร้างเซสชัน BGP เพื่อจับคู่ BGP กับ VPC การกำหนดเส้นทางและ Cloud Router ภายในองค์กร
interface_hub_name="if-hub-to-prem"
hub_router_ip="169.254.1.1"
gcloud compute routers add-interface "${routing_vpc_router_name}" \
--interface-name="${interface_hub_name}" \
--ip-address="${hub_router_ip}" \
--mask-length=30 \
--vpn-tunnel="${routing_vpc_tunnel_name}" \
--region="${region}"
bgp_hub_name="bgp-hub-to-prem"
prem_router_ip="169.254.1.2"
gcloud compute routers add-bgp-peer "${routing_vpc_router_name}" \
--peer-name="${bgp_hub_name}" \
--peer-ip-address="${prem_router_ip}" \
--interface="${interface_hub_name}" \
--peer-asn="${on_prem_router_asn}" \
--region="${region}"
interface_prem_name="if-prem-to-hub"
gcloud compute routers add-interface "${on_prem_router_name}" \
--interface-name="${interface_prem_name}" \
--ip-address="${prem_router_ip}" \
--mask-length=30 \
--vpn-tunnel="${on_prem_tunnel_name}" \
--region="${region}"
bgp_prem_name="bgp-prem-to-hub"
gcloud compute routers add-bgp-peer "${on_prem_router_name}" \
--peer-name="${bgp_prem_name}" \
--peer-ip-address="${hub_router_ip}" \
--interface="${interface_prem_name}" \
--peer-asn="${routing_vpc_router_asn}" \
--region="${region}"
โดยค่าเริ่มต้น ระบบจะไม่ประกาศเครือข่ายย่อยของ NCC Hub ไปยัง Spoke แบบไฮบริด ในขั้นตอนถัดไป ให้กำหนดค่า Cloud Router เพื่อประกาศเส้นทางเครือข่ายย่อย NCC ไปยังเครือข่ายภายในองค์กร
โฆษณาซับเน็ตของ VPC Spoke ไปยัง Cloud Router ภายในองค์กร
gcloud compute routers update "${routing_vpc_router_name}" \
--advertisement-mode custom \
--set-advertisement-groups=all_subnets \
--set-advertisement-ranges="${vpc_spoke_subnet_ip_range}" \
--region="${region}"
โฆษณาซับเน็ตภายในองค์กรไปยัง Cloud Router ของ VPC ที่กำหนดเส้นทาง
gcloud compute routers update "${on_prem_router_name}" \
--advertisement-mode custom \
--set-advertisement-groups=all_subnets \
--region="${region}"
อัปเดตการกำหนดค่าการ Peering BGP ของ Cloud Router ในองค์กรเพื่อประกาศคำนำหน้าที่มีค่า MED เป็น "111" ในส่วนถัดไป เราจะดูพฤติกรรมของ NCC ที่มีค่า BGP Med
on_prem_router_name="on-prem-router"
bgp_prem_name="bgp-prem-to-hub"
gcloud compute routers update-bgp-peer "${on_prem_router_name}" \
--peer-name="${bgp_prem_name}" \
--advertised-route-priority="111" \
--region="${region}"
ตรวจสอบสถานะของอุโมงค์ VPC การกำหนดเส้นทาง
gcloud compute vpn-tunnels describe routing-vpc-tunnel \
--region=us-central1 \
--format='flattened(status,detailedStatus)'
ตรวจสอบสถานะของ Cloud Router ของ VPC การกำหนดเส้นทาง
ใช้คำสั่ง gcloud เพื่อแสดงเส้นทางที่ BGP ของ Cloud Router VPC การกำหนดเส้นทางได้เรียนรู้
gcloud compute routers get-status routing-vpc-cr \
--region=us-central1
4. ฮับ Network Connectivity Center
ภาพรวม
ในส่วนนี้ เราจะกำหนดค่า NCC Hub โดยใช้คำสั่ง gcloud NCC Hub จะทำหน้าที่เป็นระนาบควบคุมที่รับผิดชอบในการสร้างการกำหนดค่าการกำหนดเส้นทางระหว่างแต่ละ VPC Spoke

เปิดใช้บริการ API
เปิดใช้ API การเชื่อมต่อเครือข่ายในกรณีที่ยังไม่ได้เปิดใช้
gcloud services enable networkconnectivity.googleapis.com
สร้าง NCC Hub
สร้างฮับ NCC โดยใช้คำสั่ง gcloud
hub_name="mesh-hub"
gcloud network-connectivity hubs create "${hub_name}"
ตัวอย่างเอาต์พุต
Create request issued for: [mesh-hub]
Waiting for operation [projects/ncc/locations/global/operations/operation-1719930559145-61c448a0426e4-2d18c8dd-7107edbe] to complete...done.
Created hub [mesh-hub].
อธิบายฮับ NCC ที่สร้างขึ้นใหม่ จดชื่อและเส้นทางที่เชื่อมโยงไว้
gcloud network-connectivity hubs describe mesh-hub
createTime: '2024-07-02T14:29:19.260054897Z'
exportPsc: false
name: projects/ncc/locations/global/hubs/mesh-hub
policyMode: PRESET
presetTopology: MESH
routeTables:
- projects/ncc/locations/global/hubs/mesh-hub/routeTables/default
state: ACTIVE
uniqueId: 08f9ae88-f76f-432b-92b2-357a85fc83aa
updateTime: '2024-07-02T14:29:32.583206925Z'
NCC Hub ได้เปิดตัวตารางการกำหนดเส้นทางที่กำหนดระนาบควบคุมสำหรับการสร้างการเชื่อมต่อข้อมูล ค้นหาชื่อตารางการกำหนดเส้นทางของ NCC Hub
gcloud network-connectivity hubs route-tables list --hub=mesh-hub
NAME HUB DESCRIPTION
default mesh-hub
ค้นหา URI ของตารางเส้นทางเริ่มต้นของ NCC
gcloud network-connectivity hubs route-tables describe default --hub=mesh-hub
createTime: '2024-07-02T14:29:22.340190411Z'
name: projects/ncc/locations/global/hubs/mesh-hub/routeTables/default
state: ACTIVE
uid: fa2af78b-d416-41aa-b442-b8ebdf84f799
แสดงเนื้อหาของตารางการกำหนดเส้นทางเริ่มต้นของ NCC Hub หมายเหตุ* ตารางเส้นทางของฮับ NCC จะว่างเปล่าจนกว่าจะมีการกำหนดเครือข่ายย่อยแบบไฮบริดของ NCC หรือเครือข่ายย่อย VPC
gcloud network-connectivity hubs route-tables routes list --hub=mesh-hub --route_table=default
ตารางเส้นทางของ NCC Hub ควรว่างเปล่า
5. NCC ที่มีเครือข่ายย่อยแบบไฮบริดและ VPC
ภาพรวม
ในส่วนนี้ คุณจะกำหนดค่า NCC Spoke 2 รายการโดยใช้คำสั่ง gCloud โดย Spoke หนึ่งจะเป็น VPC Spoke และอีก Spoke หนึ่งจะเป็น Hybrid Spoke (VPN)

กำหนดค่า VPC สำหรับภาระงานเป็นเครือข่ายย่อย NCC
กำหนดค่า VPC ของภาระงานเป็นเครือข่ายย่อย NCC และกำหนดให้กับฮับ NCC ที่สร้างไว้ก่อนหน้านี้ การเรียก API ของ NCC Speak ต้องระบุตำแหน่ง Flag "–global" ช่วยให้ผู้ใช้ไม่ต้องระบุเส้นทาง URI แบบเต็มเมื่อกำหนดค่า Spoke ของ NCC ใหม่
vpc_spoke_name="workload-vpc-spoke"
vpc_spoke_network_name="workload-vpc"
gcloud network-connectivity spokes linked-vpc-network create "${vpc_spoke_name}" \
--hub="${hub_name}" \
--vpc-network="${vpc_spoke_network_name}" \
--global
Create request issued for: [workload-vpc-spoke]
Waiting for operation [projects/ncc/locations/global/operations/operation-1719931097138-61c44aa15463f-90de22c7-40c10e6b] to complete...done.
Created spoke [workload-vpc-spoke].
createTime: '2024-07-02T14:38:17.315200822Z'
group: projects/ncc/locations/global/hubs/mesh-hub/groups/default
hub: projects/ncc/locations/global/hubs/mesh-hub
linkedVpcNetwork:
uri: https://www.googleapis.com/compute/v1/projects/ncc/global/networks/workload-vpc
name: projects/ncc/locations/global/spokes/workload-vpc-spoke
spokeType: VPC_NETWORK
state: ACTIVE
uniqueId: 33e50612-9b62-4ec7-be6c-962077fd47dc
updateTime: '2024-07-02T14:38:44.196850231Z'
กำหนดค่าอุโมงค์ VPN ใน VPC การกำหนดเส้นทางเป็น Spoke แบบไฮบริด
ใช้คำสั่ง gcloud นี้เพื่อกำหนดค่าอุโมงค์ VPN เป็นก้านแบบไฮบริดเพื่อเข้าร่วมฮับแบบเมช
vpn_spoke_name="hybrid-spoke"
routing_vpc_tunnel_name="routing-vpc-tunnel"
region="us-central1"
hub_name="mesh-hub"
gcloud network-connectivity spokes linked-vpn-tunnels create "${vpn_spoke_name}" \
--region="${region}" \
--hub="${hub_name}" \
--vpn-tunnels="${routing_vpc_tunnel_name}"
เอาต์พุตตัวอย่าง
Create request issued for: [hybrid-spoke]
Waiting for operation [projects/ncc/locations/us-central1/operations/operation-1719932916561-61c45168774be-0a06ae03-88192175] to complete...done.
Created spoke [hybrid-spoke].
ยืนยันการกำหนดค่า Spoke ของ Mesh-Hub
ใช้คำสั่ง gcloud เพื่อแสดงเนื้อหาของตารางการกำหนดเส้นทางเริ่มต้นของ NCC Hub
gcloud network-connectivity hubs list-spokes mesh-hub
วิเคราะห์ตารางการกำหนดเส้นทางเริ่มต้นของ Mesh Hub
ใช้คำสั่ง gcloud เพื่อแสดงเนื้อหาของตารางการกำหนดเส้นทางเริ่มต้นของ NCC Hub
gcloud network-connectivity hubs route-tables routes list --hub=mesh-hub \
--route_table=default
ระบบจะเผยแพร่คำนำหน้าที่ Cloud Router เรียนรู้ซึ่งมีค่า MED ของ BGP ไปยัง Spoke ของ NCC เมื่อใช้การแลกเปลี่ยนเส้นทางแบบไดนามิกกับ Spoke แบบไฮบริดของ NCC
ใช้คำสั่ง gcloud เพื่อดูค่าลำดับความสำคัญของ "111"
gcloud network-connectivity hubs route-tables routes list \
--hub=mesh-hub \
--route_table=default \
--effective-location=us-central1 \
--filter=10.0.3.0/24
6. ยืนยันเส้นทางข้อมูล
ในขั้นตอนนี้ เราจะตรวจสอบเส้นทางข้อมูลระหว่าง NCC แบบไฮบริดและ VPC Spoke 
ใช้เอาต์พุตจากคำสั่ง gcloud เหล่านี้เพื่อเข้าสู่ระบบ VM ในองค์กร
gcloud compute instances list --filter="name=vm3-onprem"
เข้าสู่ระบบอินสแตนซ์ VM ที่อยู่ในเครือข่ายในองค์กร
gcloud compute ssh vm3-onprem --zone=us-central1-a
ในเทอร์มินัลของ vm3-onprem ให้ใช้คำสั่ง curl เพื่อสร้างเซสชันเว็บไปยัง VM ที่โฮสต์ใน workload-vpc
curl 10.0.1.2 -v
* Trying 10.0.1.2:80...
* Connected to 10.0.1.2 (10.0.1.2) port 80 (#0)
> GET / HTTP/1.1
> Host: 10.0.1.2
> User-Agent: curl/7.74.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Wed, 03 Jul 2024 15:41:34 GMT
< Server: Apache/2.4.59 (Debian)
< Last-Modified: Mon, 01 Jul 2024 20:36:16 GMT
< ETag: "1e-61c358c8272ba"
< Accept-Ranges: bytes
< Content-Length: 30
< Content-Type: text/html
<
<h3>Web Server: www-vm1</h3>
* Connection #0 to host 10.0.1.2 left intact
7. ล้าง
เข้าสู่ระบบ Cloud Shell แล้วลบทรัพยากร GCP
ลบอุปกรณ์ปลายทางของ NCC
gcloud network-connectivity spokes delete workload-vpc-spoke --global \
--quiet
gcloud network-connectivity spokes delete hybrid-spoke \
--quiet \
--region us-central1
ลบ NCC Hub
gcloud network-connectivity hubs delete mesh-hub --quiet
ลบกฎไฟร์วอลล์
gcloud compute firewall-rules delete onprem-vpc-port-firewall-prem onprem-vpc-protocol-firewall routing-vpc--port-fw routing-vpc-protocol-fw workload-port-firewall-vpc workload-protocol-fw-vpc --quiet
ลบอุโมงค์ HA VPN
gcloud compute vpn-tunnels delete on-prem-tunnel \
--region=us-central1 \
--quiet
gcloud compute vpn-tunnels delete routing-vpc-tunnel \
--region=us-central1 \
--quiet
ลบเกตเวย์ VPN
gcloud compute vpn-gateways delete on-prem-vpn-gateway \
--region=us-central1 --quiet
gcloud compute vpn-gateways delete routing-vpc-vpn-gateway \
--region us-central1 --quiet
ลบ Cloud Router
gcloud compute routers delete routing-vpc-cr --region us-central1 --quiet
gcloud compute routers delete on-prem-router --region us-central1 --quiet
ลบอินสแตนซ์ GCE
gcloud compute instances delete vm1-vpc-workload \
--zone=us-central1-a \
--quiet
gcloud compute instances delete vm2-vpc-routing \
--zone=us-central1-a \
--quiet
gcloud compute instances delete vm3-onprem \
--zone=us-central1-a \
--quiet
ลบซับเน็ต VPC
gcloud compute networks subnets delete workload-subnet --region us-central1 --quiet
gcloud compute networks subnets delete on-prem-subnet --region us-central1 --quiet
gcloud compute networks subnets delete routing-vpc-subnet --region us-central1 --quiet
ลบ VPC
gcloud compute networks delete on-prem-net-vpcworkload-vpc routing-vpc
--quiet
8. ยินดีด้วย
คุณได้ทำแล็บ Connectivity Center ของเครือข่ายการแลกเปลี่ยนเส้นทางแบบไดนามิกเสร็จสมบูรณ์แล้ว
สิ่งที่คุณครอบคลุม
- การแลกเปลี่ยนเส้นทางแบบไดนามิกด้วยศูนย์การเชื่อมต่อเครือข่าย
ขั้นตอนถัดไป
©Google, LLC หรือบริษัทในเครือ สงวนลิขสิทธิ์ ห้ามเผยแพร่