本页面介绍了如何配置 NCC 网关通告路由。每个 NCC 网关通告路由都安装在 NCC 网关 spoke 连接到的 Network Connectivity Center hub 的路由表中。NCC 网关本身是其通告的每个路由的下一个跃点。在优先级方面,NCC 网关通告路由遵循标准最佳路径选择模式。
NCC 网关通告路由提供路径,以便 hub 的其他 spoke 中的资源将数据包发送到相应的 NCC 网关。
创建 NCC 网关通告路由
如需为从 VPC 网络到 NCC 网关的流量创建路由,请按照以下步骤操作:
gcloud
使用 gcloud beta network-connectivity spokes gateways advertised-routes create
命令:
gcloud beta network-connectivity spokes gateways advertised-routes create ROUTE_NAME \ --region=REGION \ --project=PROJECT \ --spoke=SPOKE_NAME \ --ip-range=IP_RANGE \ --priority=PRIORITY \ --advertise-to-hub
替换以下内容:
ROUTE_NAME
:您要创建的 NCC 网关通告路由的名称REGION
:包含 NCC 网关的区域PROJECT
:包含 NCC 网关的项目的 IDSPOKE_NAME
:网关 spoke 的名称IP_RANGE
:NCC 网关通告路由的目标 IP 地址范围。PRIORITY
:通告路由的优先级。默认值为 0。
API
使用 projects.locations.spokes.gatewayAdvertisedRoutes
方法,并指定 IP 地址范围和优先级:
POST https://networkconnectivity.googleapis.com/v1beta/projects/PROJECT/locations/REGION/spokes/SPOKE_NAME/gatewayAdvertisedRoutes { "ip_range": "IP_RANGE", "priority": "PRIORITY", "recipient": "ADVERTISE_TO_HUB", }
替换以下内容:
PROJECT
:包含 NCC 网关的项目的 IDREGION
:包含 NCC 网关的区域SPOKE_NAME
:网关 spoke 的名称IP_RANGE
:NCC 网关通告路由的目标 IP 地址范围。PRIORITY
:通告路由的优先级。默认值为 0。
获取网关通告路由的详细信息
您可以按照以下步骤获取 NCC 网关通告路由的详细信息:
gcloud
使用 gcloud beta network-connectivity spokes gateways advertised-routes describe
命令:
gcloud beta network-connectivity spokes gateways advertised-routes describe ROUTE_NAME \ --region=REGION \ --project=PROJECT \ --spoke=SPOKE_NAME
替换以下内容:
ROUTE_NAME
:NCC 网关通告路由的名称REGION
:包含 NCC 网关的区域PROJECT
:包含 NCC 网关的项目的 IDSPOKE_NAME
:网关 spoke 的名称
API
将 projects.locations.spokes.gatewayAdvertisedRoutes.get
方法与空白请求正文搭配使用。
GET https://networkconnectivity.googleapis.com/v1beta/projects/PROJECT/regions/REGION/spokes/SPOKE_NAME/gatewayAdvertisedRoutes/ROUTE_NAME
替换以下内容:
PROJECT
:包含 NCC 网关的项目的 IDREGION
:包含 NCC 网关的区域SPOKE_NAME
:网关 spoke 的名称ROUTE_NAME
:NCC 网关通告路由的名称
查看网关通告路由列表
您可以按照以下步骤查看 NCC 网关通告路由的列表。
gcloud
使用 gcloud beta network-connectivity spokes gateways advertised-routes list
命令:
gcloud beta network-connectivity spokes gateways advertised-routes list \ --region=REGION \ --project=PROJECT \ --spoke=SPOKE_NAME
替换以下内容:
REGION
:包含 NCC 网关的区域PROJECT
:包含 NCC 网关的项目的 IDSPOKE_NAME
:网关 spoke 的名称
API
将 projects.locations.spokes.gatewayAdvertisedRoutes.list
方法与空白请求正文搭配使用。
LIST https://networkconnectivity.googleapis.com/v1beta/projects/PROJECT/regions/REGION/spokes/SPOKE_NAME/gatewayAdvertisedRoutes
替换以下内容:
PROJECT
:包含 NCC 网关的项目的 IDREGION
:包含 NCC 网关的区域SPOKE_NAME
:网关 spoke 的名称
删除通告路由
您可以按照以下步骤删除 NCC 网关通告路由:
gcloud
使用 gcloud beta network-connectivity spokes gateways advertised-routes delete
命令:
gcloud beta network-connectivity spokes gateways advertised-routes delete ROUTE_NAME \ --region=REGION \ --project=PROJECT \ --spoke=SPOKE_NAME
替换以下内容:
ROUTE_NAME
:要删除的 NCC 网关通告路由的名称REGION
:包含 NCC 网关的区域PROJECT
:包含 NCC 网关的项目的 IDSPOKE_NAME
:网关 spoke 的名称
API
将 projects.locations.spokes.gatewayAdvertisedRoutes.delete
方法与空白请求正文搭配使用。
DELETE https://networkconnectivity.googleapis.com/v1beta/projects/PROJECT/regions/REGION/spokes/SPOKE_NAME/gatewayAdvertisedRoutes/ROUTE_NAME
替换以下内容:
PROJECT
:包含 NCC 网关的项目的 IDREGION
:包含 NCC 网关的区域SPOKE_NAME
:网关 spoke 的名称ROUTE_NAME
:要删除的 NCC 网关通告路由的名称
后续步骤
- 如需了解 NCC 网关,请参阅 NCC 网关概览。
- 如需了解如何配置 NCC 网关,请参阅 NCC 网关设置概览。
- 如需查找常见问题的解决方案,请参阅排查 Network Connectivity Center 问题。
- 如需获取有关 API 和 Google Cloud CLI 命令的详细信息,请参阅 API 和参考文档。