1. บทนำ
ภาพรวม
ในห้องทดลองนี้ ผู้ใช้จะได้สำรวจวิธีใช้ Network Connectivity Center (NCC) เพื่อสร้างการเชื่อมต่อในองค์กรในวงกว้างผ่านการสนับสนุน Spoke ของ VPC และการแลกเปลี่ยนเส้นทางแบบไดนามิก เมื่อผู้ใช้กำหนด VPC เป็น Spoke ของ VPC จะช่วยให้ผู้ใช้เชื่อมต่อ VPC กับเครือข่าย VPC หลายเครือข่ายได้ผ่านฮับ NCC หากต้องการสร้างการเชื่อมต่อเครือข่ายกับเครือข่ายภายในองค์กรของผู้ใช้ ผู้ใช้สามารถแนบ NIC เสมือนของแอปเพลiance เราเตอร์ อุโมงค์ HA_VPN หรือไฟล์แนบ VLAN ของ Interconnect กับฮับ NCC เดียวกันกับ Spoke ของ VPC ใน NCC
ทรัพยากรฮับเป็นรูปแบบการจัดการการเชื่อมต่อจากส่วนกลางเพื่อเชื่อมต่อกับสโปーク
สิ่งที่คุณจะสร้าง
ในโค้ดแล็บนี้ คุณจะได้สร้างโทโพโลยีฮับและ Spoke เชิงตรรกะด้วยฮับ NCC ที่จะใช้การเชื่อมต่อแบบผสมระหว่างเครือข่ายภายในองค์กรกับ VPC สำหรับภาระงาน
สิ่งที่คุณจะได้เรียนรู้
- ความแตกต่างระหว่าง VPC สำหรับภาระงานกับ VPC สำหรับการกําหนดเส้นทาง
- การผสานรวม NCC ของ Spoke VPC และ Spoke แบบผสม
สิ่งที่ต้องมี
- ความรู้เกี่ยวกับเครือข่าย VPC ของ GCP
- ความรู้เกี่ยวกับเราเตอร์ระบบคลาวด์และการกำหนดเส้นทาง BGP
- โปรเจ็กต์ Google Cloud
- ตรวจสอบโควต้า: เครือข่ายและขอเครือข่ายเพิ่มเติมหากจำเป็น โปรดดูภาพหน้าจอด้านล่าง
วัตถุประสงค์
- ตั้งค่าสภาพแวดล้อม GCP
- กำหนดค่าศูนย์การเชื่อมต่อเครือข่ายโดยใช้ VPC เป็น Spoke
- กำหนดค่าศูนย์การเชื่อมต่อเครือข่ายด้วยอุโมงค์ HA-VPN เป็น Spoke แบบผสม
- ตรวจสอบเส้นทางข้อมูล
- สำรวจฟีเจอร์ความสามารถในการให้บริการของ NCC
- ล้างทรัพยากรที่ใช้แล้ว
ก่อนเริ่มต้น
คอนโซล Google Cloud และ Cloud Shell
เราจะใช้ทั้ง Google Cloud Console และ Cloud Shell ตลอดทั้งห้องทดลองนี้เพื่อโต้ตอบกับ GCP
NCC Hub Project Google Cloud Console
ไปที่คอนโซลระบบคลาวด์ได้ที่ https://console.cloud.google.com
ตั้งค่ารายการต่อไปนี้ใน Google Cloud เพื่อให้กำหนดค่าศูนย์การเชื่อมต่อเครือข่ายได้ง่ายขึ้น
ในคอนโซล Google Cloud ให้เลือกหรือสร้างโปรเจ็กต์ Google Cloud ในหน้าตัวเลือกโปรเจ็กต์
เปิด Cloud Shell Codelab นี้ใช้ตัวแปร $เพื่อช่วยให้การติดตั้งใช้งานการกําหนดค่า 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 - อนุญาตให้ผู้ดูแลระบบเครือข่ายจัดการฮับและ Spoke | networkconnectivity.hubs.networkconnectivity.spokes. |
networkconnectivity.networkSpokeManager - อนุญาตให้เพิ่มและจัดการ Spoke ในฮับ สำหรับใช้ใน VPC ที่แชร์ซึ่งโปรเจ็กต์โฮสต์เป็นเจ้าของฮับ แต่ผู้ดูแลระบบคนอื่นๆ ในโปรเจ็กต์อื่นๆ สามารถเพิ่ม Spoke สำหรับไฟล์แนบของตนลงในฮับได้ | networkconnectivity.spokes.** |
networkconnectivity.networkUsernetworkconnectivity.networkViewer - อนุญาตให้ผู้ใช้เครือข่ายดูแอตทริบิวต์ต่างๆ ของฮับและ Spoke | networkconnectivity.hubs.getnetworkconnectivity.hubs.listnetworkconnectivity.spokes.getnetworkconnectivity.spokes.listnetworkconnectivity.spokes.aggregatedList |
2. ตั้งค่าสภาพแวดล้อมเครือข่าย
ภาพรวม
ในส่วนนี้ เราจะติดตั้งใช้งานเครือข่าย VPC 3 เครือข่ายและกฎไฟร์วอลล์ในโปรเจ็กต์เดียว แผนภาพเชิงตรรกะแสดงสภาพแวดล้อมเครือข่ายที่จะตั้งค่าในขั้นตอนนี้ วัตถุประสงค์ของโค้ดแล็บนี้คือการใช้ VPC เพื่อจำลองเครือข่ายภายในองค์กร
แนวคิดหลัก 1
VPC ทั่วโลกของ Google Cloud มอบการเชื่อมต่อเส้นทางข้อมูลระหว่างภูมิภาค GCP กว่า 44 แห่ง Cloud Router ซึ่งเป็นบริการระดับภูมิภาคจะประกาศซับเน็ตแบบไดนามิกและเผยแพร่เส้นทางที่เรียนรู้ในภูมิภาคที่มีการกําหนดค่าเราเตอร์หรือทั่วทั้งเครือข่าย VPC สิ่งที่กำหนดให้ Cloud Router นำไปใช้กับเส้นทางระดับภูมิภาคหรือทั่วโลกนั้นขึ้นอยู่กับว่าผู้ใช้กำหนดโหมดการกำหนดเส้นทางแบบไดนามิกเป็นระดับภูมิภาคหรือทั่วโลก
ในส่วนนี้ เราจะเริ่มต้นด้วยการกําหนดค่า VPC แต่ละรายการด้วยโหมดการกําหนดเส้นทางระดับภูมิภาค สำหรับส่วนที่เหลือของ Codelab นี้
- "Routing VPC" จะระบุ VPC ที่ไม่ได้กําหนดค่าเป็น Spoke ของ VPC NCC
- "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
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 แบบ HA เพื่อเชื่อมต่อเครือข่ายภายในองค์กรและเครือข่าย VPC ที่ใช้การกำหนดเส้นทางเข้าด้วยกัน
กำหนดค่าเราเตอร์ระบบคลาวด์ด้วย 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 ด้วย 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 ภายในองค์กร
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 ไปยัง Spoke แบบผสม ในขั้นตอนถัดไป ให้กำหนดค่าเราเตอร์ระบบคลาวด์เพื่อประกาศเส้นทางซับเน็ต NCC ไปยังเครือข่ายภายในองค์กร
โฆษณาซับเน็ต Spoke ของ VPC ไปยัง 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}"
โฆษณาซับเน็ตภายในองค์กรไปยังเราเตอร์ระบบคลาวด์ VPC ที่กำหนดเส้นทาง
gcloud compute routers update "${on_prem_router_name}" \
--advertisement-mode custom \
--set-advertisement-groups=all_subnets \
--region="${region}"
อัปเดตการกําหนดค่าการเพียร์ 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)'
ตรวจสอบสถานะของเราเตอร์ VPC Cloud ที่ใช้กำหนดเส้นทาง
ใช้คำสั่ง gcloud เพื่อแสดงรายการเส้นทาง BGP ที่เรียนรู้ของ Cloud Router ที่ใช้กำหนดเส้นทาง VPC
gcloud compute routers get-status routing-vpc-cr \
--region=us-central1
4. ฮับ Network Connectivity Center
ภาพรวม
ในส่วนนี้ เราจะกำหนดค่าฮับ NCC โดยใช้คำสั่ง gcloud NCC Hub จะทำหน้าที่เป็นระนาบควบคุมที่รับผิดชอบในการสร้างการกำหนดค่าการกำหนดเส้นทางระหว่าง Spoke ของ VPC แต่ละรายการ
เปิดใช้บริการ API
เปิดใช้ Network Connectivity API ในกรณีที่ยังไม่ได้เปิดใช้
gcloud services enable networkconnectivity.googleapis.com
สร้างฮับ NCC
สร้างฮับ 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 หมายเหตุ* ตารางเส้นทางของฮับ NCC จะว่างเปล่าจนกว่าจะมีการกำหนด Spoke แบบผสมของ NCC หรือ Spoke ของ VPC
gcloud network-connectivity hubs route-tables routes list --hub=mesh-hub --route_table=default
ตารางเส้นทางของฮับ NCC ควรว่างเปล่า
5. NCC ที่มี Spoke แบบผสมและ VPC
ภาพรวม
ในส่วนนี้ คุณจะต้องกําหนดค่า Spoke ของ NCC 2 รายการโดยใช้คําสั่ง gCloud โดย 1 รายการจะเป็น Spoke ของ VPC และอีกรายการจะเป็น Spoke แบบผสม (VPN)
กำหนดค่า VPC สำหรับภาระงานเป็น Spoke ของ NCC
กำหนดค่า VPC ของภาระงานเป็น Spoke ของ NCC และกำหนดให้กับฮับ NCC ที่สร้างขึ้นก่อนหน้านี้ การเรียก API ของ NCC Spoke กำหนดให้ต้องระบุตำแหน่ง 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 ที่ใช้การกําหนดเส้นทางเป็น SPOK แบบผสม
ใช้คำสั่ง gcloud นี้เพื่อกำหนดค่าอุโมงค์ VPN เป็น Spoke แบบผสมผสานเพื่อเข้าร่วม Mesh Hub
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
ระบบจะนำไปเผยแพร่คำนำหน้าที่เราเตอร์ระบบคลาวด์เรียนรู้ซึ่งมีค่า BGP MED ไปยัง 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 แบบผสมกับ Spoke ของ VPC
ใช้เอาต์พุตจากคำสั่ง 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
ลบ Spokes ของ NCC
gcloud network-connectivity spokes delete workload-vpc-spoke --global \
--quiet
gcloud network-connectivity spokes delete hybrid-spoke \
--quiet \
--region us-central1
ลบฮับ NCC
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. ยินดีด้วย
คุณทำ Dynamic Route Exchange Network Connectivity Center Lab เสร็จแล้ว
สิ่งที่คุณครอบคลุม
- การแลกเปลี่ยนเส้นทางแบบไดนามิกกับศูนย์การเชื่อมต่อเครือข่าย
ขั้นตอนถัดไป
©Google, LLC หรือบริษัทในเครือ สงวนลิขสิทธิ์ ห้ามเผยแพร่