管理 Cloud Router

本文說明如何列出、更新、取得狀態及刪除 Cloud Router。

事前準備

gcloud

如要使用本指南中的指令列範例,請完成下列事項:

  1. 安裝或更新至最新版 Google Cloud CLI
  2. 設定預設地區和區域

API

如要使用本指南提供的 API 範例,請設定 API 存取權

列出 Cloud Router

如要列出專案中的所有 Cloud Router,請按照下列步驟操作。

控制台

  1. 前往 Google Cloud 控制台的「Cloud Router」頁面。

    前往 Cloud Router

  2. 在「Cloud Router」頁面上,查看 Cloud Router 清單。

gcloud

請執行 list 指令。如要讓清單只列出一個地區,請指定 --filter="region:(<var>REGION</var>)

  gcloud compute routers list \
      --project=PROJECT_ID \
      [--filter="region:(REGION)]

更改下列內容:

  • PROJECT_ID:您要列出 Cloud Router 的專案 ID
  • REGION:要列出路由器的區域,例如 asia-east1

輸出結果會與下列內容相似:

  NAME        REGION       NETWORK
  my-router   asia-east1   my-network

API

請使用 routers.aggregatedList 方法:

GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/aggregated/routers

PROJECT_ID 替換為要列出 Cloud Router 的專案 ID。

如要只列出特定區域的 Cloud Router,請使用 routers.list 方法:

GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/routers

更改下列內容:

  • PROJECT_ID:您要列出 Cloud Router 的專案 ID
  • REGION:要列出 Cloud Router 的區域

更新 Cloud Router

如果 Cloud Router 與 NCC 閘道相關聯,請注意下列事項:

  • 你無法更新「ncc_gateway」欄位。
  • patchupdate 方法不會接受要求主體中的 network 欄位。

gcloud

使用 gcloud compute routers update 指令

gcloud compute routers update ROUTER_NAME
    --region=REGION

更改下列內容:

  • ROUTER_NAME:要更新的 Cloud Router 名稱
  • REGION:Cloud Router 所在的區域

API

請使用 routers.update 方法:

PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/routers/ROUTER_NAME

更改下列內容:

  • PROJECT_ID:您要列出 Cloud Router 的專案 ID
  • REGION:Cloud Router 所在的區域
  • ROUTER_NAME:要更新的 Cloud Router 名稱

取得 Cloud Router 狀態

gcloud

使用 gcloud compute routers get-status 指令。

gcloud compute routers get-status ROUTER_NAME \
    --project=PROJECT_ID \
    --region=REGION

更改下列內容:

  • ROUTER_NAME:要取得狀態的 Cloud Router 名稱
  • PROJECT_ID:Cloud Router 所屬的專案 ID
  • REGION:Cloud Router 所在的區域

API

使用 routers.getRouterStatus 方法,並將要求主體留空:

GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/routers/ROUTER_NAME/getRouterStatus

更改下列內容:

  • PROJECT_ID:Cloud Router 所屬的專案 ID
  • REGION:Cloud Router 所在的區域
  • ROUTER_NAME:要取得狀態的 Cloud Router 名稱

刪除 Cloud Router

刪除 Cloud Router 前,請先確認是否有其他資源 (例如 Cloud VPN 通道或 VLAN 連結) 正在使用這個路由器。您必須先刪除關聯的資源,才能刪除 Cloud Router。不過,您不需要移除 BGP 工作階段即可刪除 Cloud Router。

如要刪除 Cloud Router,請按照下列步驟操作。

控制台

  1. 前往 Google Cloud 控制台的「Cloud Router」頁面。

    前往 Cloud Router

  2. 勾選要刪除的 Cloud Router 旁的核取方塊。

  3. 按一下 「Delete」(刪除)

gcloud

請執行 delete 指令。指定要刪除的 Cloud Router 名稱和位置。

gcloud compute routers delete ROUTER_NAME \
    --project=PROJECT_ID \
    --region=REGION

更改下列內容:

  • ROUTER_NAME:要刪除的 Cloud Router 名稱

  • PROJECT_ID:包含要刪除的 Cloud Router 的專案 ID

  • REGION:Cloud Router 所在的區域

輸出結果會與下列內容相似:

Deleted [https://www.googleapis.com/compute/v1/projects/PROJECT_ID/regions/asia-east1/routers/ROUTER_NAME].

API

請使用 routers.delete 方法:

DELETE https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/routers/ROUTER_NAME

更改下列內容:

  • PROJECT_ID:包含要刪除的 Cloud Router 的專案 ID
  • REGION:Cloud Router 所在的區域
  • ROUTER_NAME:Cloud Router 的名稱

後續步驟

  • 如要查看 Cloud Router 的設定、BGP 工作階段,以及 Cloud Router 通告的路徑,請參閱「查看路由器詳細資料」。
  • 如要排解使用 Cloud Router 時的問題,請參閱疑難排解