查看路由器详情
本页面介绍如何查看 Cloud Router 路由器及其 BGP 会话的详细信息,包括:
- Cloud Router 路由器的 BGP 会话的状态
- Cloud Router BGP keepalive 设置
- 双向转发检测 (BFD) 设置
- Cloud Router 路由器及其 BGP 会话的路由通告设置
- Cloud Router 路由器在计算路由指标时使用的通告路由的基准优先级
BGP 会话的所有路由使用相同的通告路由的基准优先级。如需了解详情,请参阅通告的前缀和优先级。如果未指定任何值,则通告路由的基准优先级为默认值 100
。
如需详细了解 BGP 配置问题和路由处理问题,请参阅问题排查页面。
准备工作
如果您要使用本指南中的命令行示例,请执行以下操作:
- 安装或更新到 Google Cloud CLI 的最新版本。
- 设置默认区域和可用区。
如果希望使用本指南中的 API 示例,请设置 API 访问权限。
查看 Cloud Router 路由器状态和路由
如需查看 Cloud Router 路由器状态和路由,请按照以下步骤操作。
控制台
如需检查 BGP 会话的状态,请执行以下操作:
在 Google Cloud Console 中,前往 Cloud Router 路由器页面。
查看 BGP 会话列。
- 带有对勾标记的绿色圆圈表示会话已建立。
- 带有英文感叹号的红色圆圈表示会话仍在建立过程中或已失败。
如需了解详情,请将鼠标指针悬停在该感叹号上。如果会话仍在建立过程中,请等待几分钟,然后重新加载页面以验证会话是否已建立。如果会话失败,请查看日志以了解有关会话的信息。如需了解详情,请参阅查看日志和指标。
查看路由器已通告的路由
在 Google Cloud Console 中,前往 Cloud Router 路由器页面。
点击路由器的名称以打开路由器详情页面。
在 BGP 会话下,点击要查看其通告的路由的 BGP 会话的名称。
在 BGP 会话详情页面上,查看通告的路由部分。
查看 Cloud Router 路由器在网络中获知的动态路由
在 Google Cloud 控制台中,转到 VPC 路由页面。
选择动态。
确定 BGP 对等端 keepalive 时间间隔设置
在 Google Cloud Console 中,前往 Cloud Router 路由器页面。
点击要查看其信息的路由器。
在路由器详情页面的 BGP 对等端 keepalive 间隔下查看设置。
检查 BFD 会话的状态
在 Google Cloud Console 中,前往 Cloud Router 路由器页面。
点击要查看其信息的路由器。
在路由器详情页面上的 BGP 会话下,您可以确定是否已启用 BFD 以及设置了哪种 BFD 会话初始化模式。
gcloud
运行
get-status
命令并传递路由器的名称。该命令会返回路由器的状态、通告路由和已知路由。gcloud compute routers get-status ROUTER_NAME \ --project=PROJECT_ID \ --region=us-central1
请替换以下内容:
ROUTER_NAME
:Cloud Router 路由器的名称PROJECT_ID
:是包含您的 Cloud Router 路由器的项目
输出内容类似如下:
kind: compute#routerStatusResponse result: bestRoutes: — creationTimestamp: '2019-04-17T07:16:12.789-07:00' destRange: 192.168.1.0/24 kind: compute#route nextHopIp: 169.254.0.2 priority: 100 — creationTimestamp: '2019-04-17T07:16:12.789-07:00' destRange: 192.168.2.0/24 kind: compute#route nextHopIp: 169.254.0.2 priority: 338 bestRoutesForRouter: — creationTimestamp: '2019-04-17T07:15:42.012-07:00' destRange: 192.168.1.0/24 kind: compute#route nextHopIp: 169.254.0.2 priority: 100 — creationTimestamp: '2019-04-17T07:15:42.014-07:00' destRange: 192.168.2.0/24 kind: compute#route nextHopIp: 169.254.0.2 priority: 338 bgpPeerStatus: — advertisedRoutes: — destRange: 10.0.1.0/24 kind: compute#route nextHopIp: 169.254.0.1 priority: 100 — destRange: 10.0.2.0/24 kind: compute#route nextHopIp: 169.254.0.1 priority: 340 bfdStatus: bfdSessionInitializationMode: ACTIVE configUpdateTimestampMicros: '1615561369012381' controlPacketCounts: numRx: 64014 numRxRejected: 0 numRxSuccessful: 64014 numTx: 63994 controlPacketIntervals: — avgMs: '263' duration: MINUTE maxMs: '299' minMs: '225' numIntervals: '227' type: TRANSMIT — avgMs: '262' duration: MAX maxMs: '4467' minMs: '0' numIntervals: '63993' type: TRANSMIT — avgMs: '261' duration: MINUTE maxMs: '1000' minMs: '176' numIntervals: '228' type: RECEIVE localDiagnostic: NO_DIAGNOSTIC localState: UP negotiatedLocalControlTxIntervalMs: 1000 rxPacket: authenticationPresent: false controlPlaneIndependent: false demand: false diagnostic: NO_DIAGNOSTIC final: false length: 24 minEchoRxIntervalMs: 0 minRxIntervalMs: 1000 minTxIntervalMs: 1000 multiplier: 5 multipoint: false myDiscriminator: 313496190 poll: false state: UP version: 1 yourDiscriminator: 369987665 txPacket: authenticationPresent: false controlPlaneIndependent: false demand: false diagnostic: NO_DIAGNOSTIC final: false length: 24 minEchoRxIntervalMs: 0 minRxIntervalMs: 1000 minTxIntervalMs: 1000 multiplier: 5 multipoint: false myDiscriminator: 369987665 poll: false state: UP version: 1 yourDiscriminator: 313496190 uptimeMs: '16812601' enableIpv6: true ipAddress: 169.254.0.1 ipv6NexthopAddress: 2600:2d00:0:0:0:0:1:5 linkedVpnTunnel: https://www.googleapis.com/compute/projects/PROJECT_ID/regions/us-central1/vpnTunnels/vpn-1-tunnel-1 name: mysession2 numLearnedRoutes: 2 peerIpAddress: 169.254.0.2 peerIpv6NexthopAddress: 2600:2d00:0:0:0:0:1:4 state: Established status: UP uptime: 2 days, 3 hours, 37 minutes, 0 seconds uptimeSeconds: '185820' network: https://www.googleapis.com/compute/kind: compute#routerStatusResponse
API
使用 routers.getRouterStatus
方法:
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/routers/ROUTER_NAME/getRouterStatus
请替换以下内容:
PROJECT_ID
:Cloud Router 路由器所属的项目REGION
:Cloud Router 路由器所在的区域ROUTER_NAME
:Cloud Router 路由器的名称
查看 BGP 会话配置
如需查看现有 BGP 会话的配置,请按照以下步骤操作。
控制台
在 Google Cloud 控制台中,前往 Cloud Router 路由器页面。
从路由器列表中选择包含要查看的 BGP 会话的路由器。
查看 BGP 会话部分,了解 Cloud Router 路由器的 BGP 会话详细信息。
gcloud
运行
describe
命令并传递 Cloud Router 路由器的名称。gcloud compute routers describe ROUTER_NAME / --project PROJECT_ID / --region REGION
请替换以下内容:
ROUTER_NAME
:Cloud Router 路由器的名称PROJECT_ID
:是包含您的 Cloud Router 路由器的项目REGION
:Cloud Router 路由器所在的区域
查看输出内容中的
bgpPeers
部分:bgp: advertiseMode: DEFAULT asn: 65001 keepaliveInterval: 120 bgpPeers: — advertiseMode: DEFAULT bfd: minReceiveInterval: 1000 minTransmitInterval: 1000 mode: ACTIVE multiplier: 5 enable: 'TRUE' enableIpv6: true interfaceName: if-mysession2 ipAddress: 169.254.0.1 ipv6NexthopAddress: 2600:2d00:0:0:0:0:1:5 name: mysession2 peerAsn: 65002 peerIpAddress: 169.254.0.2 peerIpv6NexthopAddress: 2600:2d00:0:0:0:0:1:6 creationTimestamp: '2019-03-15T13:48:12.433-07:00' description: '' id: '1234567890123456789' interfaces: — ipRange: 169.254.0.1/30 linkedVpnTunnel: https://www.googleapis.com/compute/projects/PROJECT_ID/regions/us-central1/vpnTunnels/vpn-1-tunnel-1 name: if-mysession2 kind: compute#router name: ROUTER_NAME network: https://www.googleapis.com/compute/projects/PROJECT_ID/global/networks/network-a region: https://www.googleapis.com/compute/projects/PROJECT_ID/regions/us-central1 selfLink: https://www.googleapis.com/compute/projects/PROJECT_ID/regions/us-central1/routers/ROUTER_NAME selfLinkWithId: https://www.googleapis.com/compute/projects/PROJECT_ID/regions/us-central1/routers/7114728016518951267
API
使用 routers.get
方法:
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/routers/ROUTER_NAME
请替换以下内容:
PROJECT_ID
:Cloud Router 路由器所属的项目REGION
:Cloud Router 路由器所在的区域ROUTER_NAME
:Cloud Router 路由器的名称
输出中的 bgpPeers[]
字段包含每个 BGP 会话的配置。
后续步骤
如需更新通告路由的基准优先级,请参阅更新通告路由的基准优先级。
如需更新路由通告,请参阅自定义路由通告。
如需了解 BGP 会话状态,请参阅 BGP 会话状态。
如需排查使用 Cloud Router 时遇到的问题,请参阅问题排查。