目標
本教學課程將說明如何完成下列工作:
- 建立自訂虛擬私有雲網路,其中包含不同區域的兩個子網路。
- 在下列每個區域中建立虛擬機器 (VM) 執行個體:美國和新加坡。
- 建立 Cloud Router 和 Cloud NAT 閘道,允許美國 VM 存取公開網際網路。
- 建立全域網路防火牆政策,並新增防火牆規則來啟用 Identity-Aware Proxy (IAP)。
- 在新加坡 VM 上安裝 Apache 伺服器。
- 新增防火牆規則,封鎖特定地理位置的流量。
- 測試地理位置防火牆規則。
下圖顯示自訂 VPC 網路中 us-central1
和 asia-southeast1
區域的 VM 之間的流量。全域網路防火牆政策會封鎖傳送至特定地理位置的輸出流量。us-central1
區域中的 VM 使用 Cloud Router 和 Cloud NAT 存取網際網路,而不使用外部 IP 位址。us-central1
區域中的 VM 會使用 asia-southeast1
區域中 VM 的外部 IP 位址,測試防火牆規則。
事前準備
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
- 確認您具備 Compute 網路管理員角色 (
roles/compute.networkAdmin
)。 -
Enable the Compute Engine and Identity-Aware Proxy (IAP) APIs.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin
), which contains theserviceusage.services.enable
permission. Learn how to grant roles. - 如果您希望透過指令列操作,請先安裝 Google Cloud CLI。如需該工具的概念與安裝資訊,請參閱 gcloud CLI 總覽。
注意:如果您先前沒有執行過 Google Cloud CLI,請執行
gcloud init
指令,初始化 gcloud CLI 目錄。
建立含子網路的自訂虛擬私有雲網路
建立含有兩個 IPv4 子網路的自訂模式虛擬私有雲網路。
主控台
在 Google Cloud 控制台中,前往「VPC networks」(虛擬私有雲網路) 頁面。
按一下「建立虛擬私有雲網路」。
在「Name」(名稱) 中輸入
vpc-geo-location
。在「子網路建立模式」部分,選取「自訂」。
在「New subnet」(新子網路) 部分,指定子網路的以下設定參數:
- Name (名稱):
subnet-1-us
- Region (區域):
us-central1
- IPv4 範圍:
10.0.0.0/24
- Name (名稱):
按一下 [完成]。
按一下「Add subnet」(新增子網路),然後指定下列設定參數:
- Name (名稱):
subnet-2-sg
- Region (區域):
asia-southeast1
- IPv4 範圍:
192.168.200.0/24
- Name (名稱):
按一下 [完成]。
點選「建立」。
gcloud
- 如要開啟終端機,請按一下「啟用 Cloud Shell」。
如要建立 VPC 網路,請執行下列指令:
gcloud compute networks create vpc-geo-location \ --subnet-mode=custom
在「授權 Cloud Shell」對話方塊中,按一下「授權」。
如要建立子網路,請執行下列指令:
gcloud compute networks subnets create subnet-1-us \ --network=vpc-geo-location \ --region=us-central1 \ --range=10.0.0.0/24
如要建立另一個子網路,請執行下列指令:
gcloud compute networks subnets create subnet-2-sg \ --network=vpc-geo-location \ --region=asia-southeast1 \ --range=192.168.200.0/24
建立 VM
在本節中,您會在上一節設定的子網路中建立兩個 VM。
在 us-central1
區域中建立 VM
在 us-central1
區域中建立沒有外部 IP 位址的 VM。
主控台
如要在 us-central1
區域中建立 VM,請按照下列步驟操作:
前往 Google Cloud 控制台的「Create an instance」(建立執行個體) 頁面。
在「機器設定」窗格中,執行下列操作:
- 在「Name」(名稱) 中輸入
instance-1-us
。 - 在「Region」(區域) 中選取
us-central1 (Iowa)
。
- 在「Name」(名稱) 中輸入
在導覽選單中,按一下「網路」。
- 在「Network interfaces」(網路介面) 區段中,按一下
default
,然後指定下列設定參數:- 網路:
vpc-geo-location
- 「Subnetwork」(子網路):
subnet-1-us IPv4 (10.0.0.0/24)
- 「外部 IPv4 位址」:選取「無」
- 網路:
- 按一下 [完成]。
- 在「Network interfaces」(網路介面) 區段中,按一下
點選「建立」。
gcloud
如要在 us-central1
區域中建立 VM,請執行下列指令:
gcloud compute instances create instance-1-us \ --network=vpc-geo-location \ --zone=us-central1-a \ --stack-type=IPV4_ONLY \ --no-address \ --subnet=subnet-1-us
在 asia-southeast1
區域中建立 VM
主控台
如要在 asia-southeast1
區域中建立 VM,請按照下列步驟操作:
前往 Google Cloud 控制台的「Create an instance」(建立執行個體) 頁面。
在「機器設定」窗格中,執行下列操作:
- 在「Name」(名稱) 中輸入
instance-2-sg
。 - 在「區域」部分,選取「
asia-southeast1 (Singapore)
」。
- 在「Name」(名稱) 中輸入
在導覽選單中,按一下「網路」。
- 在「Network interfaces」(網路介面) 區段中,按一下
default
,然後指定下列設定參數:- 網路:
vpc-geo-location
- 「Subnetwork」(子網路):
subnet-2-sg IPv4 (192.168.200.0/24)
- 「外部 IPv4 位址」:選取「無」
- 網路:
- 按一下 [完成]。
- 在「Network interfaces」(網路介面) 區段中,按一下
點選「建立」。
gcloud
如要在 asia-southeast1
區域中建立 VM,請執行下列指令:
gcloud compute instances create instance-2-sg \ --network=vpc-geo-location \ --zone=asia-southeast1-b \ --subnet=subnet-2-sg \ --stack-type=IPV4_ONLY
建立 Cloud Router 和 Cloud NAT 閘道
在上一節中,您建立了兩個 VM,分別是 instance-1-us
和 asia-southeast1
。如要允許 instance-1-us
VM 存取公用網際網路,請建立 Cloud Router 和 Cloud NAT 閘道。
主控台
前往 Google Cloud 控制台的「Cloud NAT」頁面。
按一下「開始使用」或「建立 Cloud NAT 閘道」。
在「Gateway name」(閘道名稱) 輸入
nat-gateway
。在「NAT type」(NAT 類型) 中,選取「Public」(公開)。
在「Select Cloud Router」(選取 Cloud Router) 部分,指定下列設定參數:
- 網路:
vpc-geo-location
- 區域:
us-central1
- Cloud Router:建立新路由器。
- 在「Name」(名稱) 中輸入
router-fw-rules
。 - 點選「建立」。
- 在「Name」(名稱) 中輸入
- 網路:
點選「建立」。
前往 Google Cloud 控制台的「IP addresses」(IP 位址) 頁面。
按一下「External IP Addresses」(外部 IP 位址) 分頁標籤,然後複製 Cloud NAT 的 IP 位址 (
nat-auto-ip
)。驗證instance-1-us
VM 與instance-2-sg
VM 之間的連線時,會使用這個 IP 位址。
gcloud
如要建立 Cloud Router,請執行下列指令:
gcloud compute routers create router-fw-rules \ --network=vpc-geo-location \ --region=us-central1
如要建立 Cloud NAT 閘道,請執行下列指令:
gcloud compute routers nats create nat-gateway \ --router=router-fw-rules \ --region=us-central1 \ --auto-allocate-nat-external-ips \ --nat-all-subnet-ip-ranges
如要查看 Cloud NAT IP 位址,請執行下列指令:
gcloud compute routers get-nat-ip-info \ router-fw-rules \ --region=us-central1
請務必複製 Cloud NAT 的 IP 位址 (
natIp
)。驗證instance-1-us
VM 與instance-2-sg
VM 之間的連線時,會用到這個 IP 位址。
建立全域網路防火牆政策,啟用 IAP
在本節中,您將建立全域網路防火牆政策,並新增防火牆規則來啟用 IAP。IAP 可讓您管理 VM 執行個體的存取權。
防火牆規則具有下列特性。
- 來自 IP 範圍
35.235.240.0/20
的輸入流量。這個範圍包含 IAP 用於 TCP 轉送的所有 IP 位址。 連線至您希望透過 IAP TCP 轉送功能存取的所有通訊埠,例如適用於 SSH 的通訊埠「
22
」。
主控台
如要允許透過 IAP 存取 vpc-geo-location
網路中的所有 VM 執行個體,請按照下列步驟操作:
在 Google Cloud 控制台中,前往「Firewall policies」(防火牆政策) 頁面。
按一下「建立防火牆政策」。
在「設定政策」部分,於「政策名稱」輸入
fw-policy
。在「部署範圍」部分,選取「全域」,然後點選「繼續」。
如要為政策建立規則,請在「新增規則」部分中,按一下「新增規則」。
- 在「Priority」(優先順序) 中輸入
100
。 - 在「Direction of traffic」(流量方向) 中選取 [Ingress] (輸入)。
- 在「Action on match」(相符時執行的動作) 中選取 [Allow] (允許)。
- 針對「記錄」,選取「開啟」。
- 在「目標」部分中,針對「目標類型」選取「網路中的所有執行個體」。
- 在「來源」部分,於「IP 範圍」中輸入
35.235.240.0/20
。 - 在「通訊協定和通訊埠」部分,選取「指定的通訊協定和通訊埠」。
- 勾選「TCP」核取方塊,然後在「Ports」(通訊埠) 輸入
22
。 - 點選「建立」。
- 在「Priority」(優先順序) 中輸入
按一下「繼續」。
如要將虛擬私有雲網路與政策建立關聯,請在「將政策與虛擬私有雲網路建立關聯」部分中,按一下「建立關聯」。
勾選
vpc-geo-location
核取方塊,然後按一下「關聯」。按一下「繼續」。
點選「建立」。
gcloud
如要允許 IAP 存取 vpc-geo-location
網路中的所有 VM 執行個體,請執行下列指令:
如要建立防火牆政策,請執行下列指令:
gcloud compute network-firewall-policies create fw-policy \ --global
如要建立防火牆規則,允許流量前往所有目的地並啟用記錄,請執行下列指令:
gcloud compute network-firewall-policies rules create 100 \ --firewall-policy=fw-policy \ --direction=INGRESS \ --action=ALLOW \ --layer4-configs=tcp:22 \ --src-ip-ranges=35.235.240.0/20 \ --global-firewall-policy \ --enable-logging
如要將防火牆政策與虛擬私有雲網路建立關聯,請執行下列指令:
gcloud compute network-firewall-policies associations create \ --firewall-policy=fw-policy \ --network=vpc-geo-location \ --name=pol-association-fw-rules \ --global-firewall-policy
建立防火牆規則
在本節中,您將建立防火牆規則,允許 instance-2-sg
VM 上的連入連線。
主控台
在 Google Cloud 控制台中,前往「Firewall policies」(防火牆政策) 頁面。
在「網路防火牆政策」部分中,按一下
fw-policy
。按一下「建立規則」。
在「Priority」(優先順序) 中輸入
500
。在「Direction of traffic」(流量方向) 中選取 [Ingress] (輸入)。
在「Action on match」(相符時執行的動作) 中選取 [Allow] (允許)。
針對「記錄」,選取「開啟」。
在「目標」部分中,針對「目標類型」選取「網路中的所有執行個體」。
在「來源」部分,針對「IP 範圍」輸入 NAT_IP_ADDRESS。
將
NAT_IP_ADDRESS
替換為指派給 Cloud NAT 的 IP 位址。詳情請參閱「建立 Cloud Router 和 Cloud NAT 閘道」。點選「建立」。
gcloud
如要更新防火牆政策,請執行下列指令:
gcloud compute network-firewall-policies rules create 500 \ --firewall-policy=fw-policy \ --direction=INGRESS \ --action=ALLOW \ --src-ip-ranges=NAT_IP_ADDRESS \ --layer4-configs=all \ --global-firewall-policy \ --enable-logging
將 NAT_IP_ADDRESS
替換為指派給 Cloud NAT 的 IP 位址。詳情請參閱「建立 Cloud Router 和 Cloud NAT 閘道」。
安裝 Apache 伺服器
在本節中,您將在 instance-2-sg
VM 上安裝 Apache 伺服器。
主控台
前往 Google Cloud 控制台的「VM instances」(VM 執行個體) 頁面。
在
instance-2-sg
VM 的「連線」欄中,按一下「SSH」。在「SSH-in-browser」(直接透過瀏覽器進行 SSH 連線) 對話方塊中,按一下「Authorize」(授權),然後等待連線建立。
如要更新執行個體上的套件清單,請執行下列指令:
sudo apt-get update
程序完成後,系統會產生以下訊息:
Reading package lists... Done.
如要安裝
apache2 HTTP Server
套件,請在命令提示字元中執行下列指令:sudo apt-get install apache2 php7.0
程序進行時,系統會產生下列訊息:
After this operation, 56.0 MB of additional disk space will be used. Do you want to continue? [Y/n]
按下 Y 鍵確認,然後按下 Enter 鍵。
如要覆寫 Apache 網路伺服器預設網頁,請執行下列指令:
echo '<!doctype html><html><body><h1>Hello World!</h1></body></html>' | sudo tee /var/www/html/index.html
關閉「SSH-in-browser」(透過瀏覽器進行 SSH 連線) 對話方塊。
gcloud
如要使用 SSH 連線至
instance-2-sg
VM,請執行下列指令:gcloud compute ssh instance-2-sg \ --zone=asia-southeast1-b \ --tunnel-through-iap
系統提示時,請按下 Y 鍵確認,然後按下 Enter 鍵。
如要更新執行個體上的套件清單,請執行下列指令:
sudo apt-get update
程序完成後,系統會產生以下訊息:
Reading package lists... Done.
如要安裝
apache2 HTTP Server
套件,請在命令提示字元中執行下列指令:sudo apt-get install apache2 php7.0
程序進行時,系統會產生下列訊息:
After this operation, 56.0 MB of additional disk space will be used. Do you want to continue? [Y/n]
按下 Y 鍵確認,然後按下 Enter 鍵。
如要覆寫 Apache 網路伺服器預設網頁,請執行下列指令:
echo '<!doctype html><html><body><h1>Hello World!</h1></body></html>' | sudo tee /var/www/html/index.html
如要關閉「透過瀏覽器建立 SSH 連線」,請輸入
exit
。
驗證連線
在 instance-2-sg
VM 上安裝 Apache 伺服器後,請使用 instance-2-sg
VM 的外部 IP 位址,從 instance-2-sg
VM 連線至 instance-1-us
VM。
主控台
前往 Google Cloud 控制台的「VM instances」(VM 執行個體) 頁面。
從
instance-2-sg
VM 的「External IP」(外部 IP) 欄中,複製 VM 的外部 IP 位址。在
instance-1-us
VM 的「連線」欄中,按一下「SSH」。在「SSH-in-browser」(直接透過瀏覽器進行 SSH 連線) 對話方塊中,按一下「Authorize」(授權),然後等待連線建立。
如要驗證連線,請執行下列指令:
curl EXTERNAL_IP -m 2
將
EXTERNAL_IP
替換為instance-2-sg
VM 的 IP 位址。預期的回應訊息如下:
<!doctype html><html><body><h1>Hello World!</h1></body></html>
關閉「SSH-in-browser」(透過瀏覽器進行 SSH 連線) 對話方塊。
gcloud
如要查看
instance-2-sg
VM 的外部 IP 位址,請執行下列指令:gcloud compute instances describe instance-2-sg \ --zone=asia-southeast1-b \ --format='get(networkInterfaces[0].accessConfigs[0].natIP)'
系統提示時,請按下 Y 鍵確認,然後按下 Enter 鍵。 請務必記下
instance-2-sg
VM 的外部 IP 位址。如要使用 SSH 連線至
instance-1-us
VM,請執行下列指令:gcloud compute ssh instance-1-us \ --zone=us-central1-a \ --tunnel-through-iap
如要驗證連線,請執行下列指令:
curl EXTERNAL_IP -m 2
將
EXTERNAL_IP
替換為instance-2-sg
VM 的 IP 位址。預期的回應訊息如下:
<!doctype html><html><body><h1>Hello World!</h1></body></html>
如要關閉「透過瀏覽器建立 SSH 連線」,請輸入
exit
。
新增防火牆規則,封鎖特定地理位置的流量
在本節中,您將為 VPC vpc-geo-location
新增防火牆規則,封鎖前往義大利、波蘭和新加坡的輸出流量。
主控台
如要在「fw-policy
」中新增規則,請按照「建立全域網路防火牆政策」一節中的步驟操作:
在 Google Cloud 控制台中,前往「Firewall policies」(防火牆政策) 頁面。
在「網路防火牆政策」部分,按一下
fw-policy
。按一下「建立規則」。
在「Priority」(優先順序) 中輸入
200
。在「Direction of traffic」(流量方向) 中選取「Egress」(輸出)。
在「Action on match」(相符時執行的動作) 中選取「Deny」(拒絕)。
針對「記錄」,選取「開啟」。
在「目的地」部分,選取「地理位置」的新加坡 (SG)、波蘭 (PL) 和義大利 (IT)。
按一下 [確定]。
點選「建立」。
gcloud
如要在「建立全域網路防火牆政策」一節中建立的 fw-policy
中新增規則,請執行下列指令:
gcloud compute network-firewall-policies rules create 200 \ --firewall-policy=fw-policy \ --direction=EGRESS \ --action=DENY \ --dest-region-codes=SG,PL,IT \ --layer4-configs=all \ --global-firewall-policy \ --enable-logging
測試地理位置防火牆規則
主控台
將規則新增完畢,封鎖前往新加坡 (SG)、波蘭 (PL) 和義大利 (IT) 的輸出流量後,請按照下列步驟測試規則:
前往 Google Cloud 控制台的「VM instances」(VM 執行個體) 頁面。
從
instance-2-sg
VM 的「External IP」(外部 IP) 欄中,複製 VM 的外部 IP 位址。在
instance-1-us
VM 的「連線」欄中,按一下「SSH」。在「SSH-in-browser」(直接透過瀏覽器進行 SSH 連線) 對話方塊中,按一下「Authorize」(授權),然後等待連線建立。
如要確認傳送至
instance-2-sg
VM 的輸出流量遭到封鎖,請執行下列指令:curl EXTERNAL_IP -m 2
將
EXTERNAL_IP
替換為instance-2-sg
VM 的 IP 位址。由於您已建立防火牆規則,拒絕從美國 VM 傳送外部流量至新加坡 VM,因此系統會顯示
Connection timed out
訊息。如要確認前往波蘭的輸出流量已遭封鎖,請執行下列指令:
curl `https://www.gov.pl` -m 2
您已建立防火牆規則,拒絕外部流量連往波蘭網站,因此系統會顯示
Connection timed out
訊息。如要確認前往義大利的出站流量已遭封鎖,請執行下列指令:
curl `https://www.esteri.it/it/` -m 2
您已建立防火牆規則,拒絕外部流量連往義大利網站,因此出現
Connection timed out
訊息是正常現象。關閉「SSH-in-browser」(透過瀏覽器進行 SSH 連線) 對話方塊。
gcloud
將規則新增完畢後,請執行下列指令來測試規則:
如要查看
instance-2-sg
VM 的外部 IP 位址,請執行下列指令:gcloud compute instances describe instance-2-sg \ --format='get(networkInterfaces[0].accessConfigs[0].natIP)'
系統提示時,請按下 Y 鍵確認,然後按下 Enter 鍵。請務必記下
instance-2-sg
VM 的外部 IP 位址。如要使用 SSH 連線至
instance-1-us
VM,請執行下列指令:gcloud compute ssh instance-1-us \ --zone=us-central1-a \ --tunnel-through-iap
如要確認前往新加坡的輸出流量已遭封鎖,請執行下列指令:
curl EXTERNAL_IP -m 2
將
EXTERNAL_IP
替換為instance-2-sg
VM 的 IP 位址。由於您已建立防火牆規則,拒絕從美國 VM 傳送外部流量至新加坡 VM,因此系統會顯示
Connection timed out
訊息。如要確認前往波蘭的輸出流量已遭封鎖,請執行下列指令:
curl https://www.gov.pl -m 2
您建立的防火牆規則會拒絕來自波蘭網站的外部流量,因此出現
Connection timed out
訊息是正常情況。如要確認前往義大利的出站流量已遭封鎖,請執行下列指令:
curl https://www.esteri.it/it/ -m 2
您已建立防火牆規則,拒絕外部流量連往義大利網站,因此出現
Connection timed out
訊息是正常現象。如要關閉「透過瀏覽器建立 SSH 連線」對話方塊,請輸入
exit
。
查看記錄
您可以存取記錄,確認防火牆規則是否已套用至輸出流量。如要查看記錄詳細資料,請按照下列步驟操作:
在 Google Cloud 控制台中,前往「Firewall policies」(防火牆政策) 頁面。
在「網路防火牆政策」部分,按一下
fw-policy
名稱。按一下「資料欄顯示選項」
。在「顯示的資料欄」對話方塊中,選取「命中次數」,然後按一下「確定」。
在「命中次數」欄中,選取您在「建立全域網路防火牆政策」期間建立的規則編號。 「Logs Explorer」(記錄檔探索工具) 頁面隨即開啟。
如要查看套用至輸出流量的防火牆規則,請展開個別記錄。您可以查看連線、處置和遠端位置詳細資料。
清除所用資源
如要避免系統向您的 Google Cloud 帳戶收取本教學課程所用資源的費用,請刪除含有相關資源的專案,或者保留專案但刪除個別資源。
在本節中,您將刪除在本教學課程中建立的資源。
刪除防火牆政策
主控台
在 Google Cloud 控制台中,前往「Firewall policies」(防火牆政策) 頁面。
在「網路防火牆政策」部分,按一下
fw-policy
名稱。按一下「關聯項目」分頁標籤。
勾選
vpc-geo-location
核取方塊,然後按一下「移除關聯」。在「Remove a firewall policy association」(移除防火牆政策連結關係) 對話方塊中,按一下「Remove」(移除)。
按一下「
fw-policy
」標題旁邊的「刪除」。在「刪除防火牆政策」對話方塊中,按一下「刪除」。
gcloud
移除防火牆政策與 VPC 網路之間的關聯。
gcloud compute network-firewall-policies associations delete \ --name=pol-association-fw-rules \ --firewall-policy=fw-policy \ --global-firewall-policy
The network firewall policy does not have an association with pol-association-fw-rules.
Google Cloud刪除防火牆政策。
gcloud compute network-firewall-policies delete fw-policy \ --global
系統提示時,請按下 Y 鍵確認,然後按下 Enter 鍵。
刪除 VM
主控台
前往 Google Cloud 控制台的「VM instances」(VM 執行個體) 頁面。
選取
instance-1-us
和instance-2-sg
VM 的核取方塊。點選「刪除」。
在「Delete 2 instances?」(要刪除 2 個執行個體嗎?) 對話方塊中,按一下「Delete」(刪除)。
gcloud
如要刪除
instance-1-us
VM,請執行下列指令:gcloud compute instances delete instance-1-us \ --zone=us-central1-a
系統提示時,請按下 Y 鍵確認,然後按下 Enter 鍵。
如要刪除
instance-2-sg
VM,請執行下列指令:gcloud compute instances delete instance-2-sg \ --zone=asia-southeast1-b
系統提示時,請按下 Y 鍵確認,然後按下 Enter 鍵。
刪除 Cloud NAT 閘道和 Cloud Router
主控台
前往 Google Cloud 控制台的「Cloud routers」頁面。
勾選「
router-fw-rules
」核取方塊。點選「刪除」。
在「Delete router-fw-rules」(刪除路由器防火牆規則) 對話方塊中,按一下「Delete」(刪除)。
刪除 Cloud Router 時,相關聯的 Cloud NAT 閘道也會一併刪除。
gcloud
如要刪除 router-fw-rules
Cloud Router,請執行下列指令:
gcloud compute routers delete router-fw-rules \ --region=us-central1
系統提示時,請按下 Y 鍵確認,然後按下 Enter 鍵。
刪除 Cloud Router 時,相關聯的 Cloud NAT 閘道也會一併刪除。
刪除虛擬私有雲網路及其子網路
主控台
在 Google Cloud 控制台中,前往「VPC networks」(虛擬私有雲網路) 頁面。
在「Name」(名稱) 欄中,按一下
vpc-geo-location
。按一下「刪除虛擬私有雲網路」。
在「刪除網路」對話方塊中,按一下「刪除」。
刪除 VPC 時,子網路也會一併刪除。
gcloud
如要刪除
vpc-geo-location
虛擬私有雲網路的子網路subnet-1-us
,請執行下列指令:gcloud compute networks subnets delete subnet-1-us \ --region=us-central1
系統提示時,請按下 Y 鍵確認,然後按下 Enter 鍵。
如要刪除
vpc-geo-location
虛擬私有雲網路的子網路subnet-2-sg
,請執行下列指令:gcloud compute networks subnets delete subnet-2-sg \ --region=asia-southeast1
系統提示時,請按下 Y 鍵確認,然後按下 Enter 鍵。
如要刪除
vpc-geo-location
VPC 網路,請執行下列指令:gcloud compute networks delete vpc-geo-location
系統提示時,請按下 Y 鍵確認,然後按下 Enter 鍵。
後續步驟
- 如要瞭解防火牆政策的概念資訊,請參閱防火牆政策。
- 如要瞭解防火牆政策規則的概念資訊,請參閱防火牆政策規則。
- 如要建立、更新、監控及刪除虛擬私有雲防火牆規則,請參閱「使用虛擬私有雲防火牆規則」。
- 如要瞭解費用,請參閱 Cloud NGFW 定價。