Using the GCP API to get BGP AS Path Information

One of the trickier parts about building complex hybrid cloud networks is it’s difficult to troubleshoot scenarios where there’s multiple paths.

GCP doesn’t offer a way to view this in Web UI or CLI (gcloud), but it is accessible via the routers.getRouterStatus() method in the API. This essentially queries a specific cloud router for detailed BGP information. The JSON will look like this. Of most interest is the asPaths list.

{
  "kind": "compute#routerStatusResponse",
  "result": {
    "network": "https://www.googleapis.com/compute/v1/projects/xxx/global/networks/yyy",
    "bestRoutes": [
      {
        "kind": "compute#route",
        "creationTimestamp": "2023-06-14T13:17:31.690-07:00",
        "network": "https://www.googleapis.com/compute/v1/projects/xxx/global/networks/yyy",
        "destRange": "10.20.30.0/24",
        "priority": 100,
        "nextHopIp": "169.254.22.73",
        "nextHopVpnTunnel": "https://www.googleapis.com/compute/v1/projects/xxx/regions/us-east4/vpnTunnels/vpn-0",
        "routeType": "BGP",
        "asPaths": [
          {
            "pathSegmentType": "AS_SEQUENCE",
            "asLists": [
              4200000000
            ]
          }
        ]
      },
      {
        "kind": "compute#route",
        "creationTimestamp": "2023-06-14T13:17:31.690-07:00",
        "network": "https://www.googleapis.com/compute/v1/projects/xxx/global/networks/yyy",
        "destRange": "10.20.30.0/24",
        "priority": 100,
        "nextHopIp": "169.254.22.74",
        "nextHopVpnTunnel": "https://www.googleapis.com/compute/v1/projects/xxx/regions/us-east4/vpnTunnels/vpn-1",
        "routeType": "BGP",
        "asPaths": [
          {
            "pathSegmentType": "AS_SEQUENCE",
            "asLists": [
              4200000000
            ]
          }
        ]
      },
    ]
  }
}

Leave a comment