List BGP routes
This page describes how to list advertised routes and learned routes on individual Border Gateway Protocol (BGP) sessions, which can help you troubleshoot your Cloud Router routes. You can list routes either before or after BGP route policies are applied to a route. To troubleshoot advertised and learned routes, we recommend completing the following sections in order.
Before you begin
gcloud
If you want to use the command-line examples in this guide, do the following:
- Install or update to the latest version of the Google Cloud CLI.
- Set a default region and zone.
API
If you want to use the API examples in this guide, set up API access.
List BGP routes before policies are applied
Console
Do the following:
In the Google Cloud console, go to the Cloud Router page.
On the Cloud Router page, click the BGP sessions tab.
Select the BGP session peer that you want to list. The BGP session details page is displayed. Advertised routes are listed in the Advertised routes section.
gcloud
Use the gcloud compute routers list-bgp-routes
command:
gcloud compute routers list-bgp-routes ROUTER_NAME \
--address-family=ADDRESS_FAMILY \
--no-policy-applied \
--peer=PEER_NAME \
--region=REGION \
--route-direction=ROUTE_DIRECTION
Replace the following:
ROUTER_NAME
: the name of your Cloud RouterADDRESS_FAMILY
: the IP address family to display routes for:IPV4
: for IPv4-based BGP addressesIPV6
: for IPv6-based BGP addresses
PEER_NAME
: the name of the BGP peerREGION
: the region in which your Cloud Router is locatedROUTE_DIRECTION
: the direction to display routes for:INBOUND
: routes learned from the BGP peerOUTBOUND
: routes advertised to the BGP peer
The output is similar to the following:
---
asPaths:
- asns:
- 64515
type: AS_PATH_TYPE_SEQUENCE
destination:
prefix: 192.168.1.0/24
med: 100
origin: BGP_ORIGIN_INCOMPLETE
---
asPaths:
- asns:
- 64515
type: AS_PATH_TYPE_SEQUENCE
destination:
prefix: 192.168.2.0/24
med: 333
origin: BGP_ORIGIN_INCOMPLETE
API
Use the routers.listBgpRoutes
method:
GET https://compute.googleapis.com/compute/projects/PROJECT_ID/regions/REGION/routers/ROUTER_NAME/listBgpRoutes
{
"addressFamily": "ADDRESS_FAMILY",
"peer": "PEER_NAME",
"policyApplied": FALSE,
"routeType": "ROUTE_TYPE"
}
Replace the following:
PROJECT_ID
: the project that contains your Cloud RouterREGION
: the region in which your Cloud Router is locatedROUTER_NAME
: the name of your Cloud RouterADDRESS_FAMILY
: the IP address family to display routes for:IPV4
: for IPv4-based BGP addressesIPV6
: for IPv6-based BGP addresses
PEER_NAME
: the name of the BGP peerROUTE_TYPE
: the type of route to display:LEARNED
: route learned from the BGP peerADVERTISED
: route advertised to the BGP peer
The output is similar to the following:
{
"kind": "compute#routersListBgpRoutes",
"result": [
{
"destination": {
"prefix": "10.0.1.0/24"
},
"med": 100
},
{
"destination": {
"prefix": "10.0.2.0/24"
},
"med": 338
}
]
}
List BGP routes after policies are applied
Console
In the Google Cloud console, go to the Cloud Router page.
On the Cloud Router page, click the BGP sessions tab.
Select the BGP session peer that you want to list. The BGP session details page is displayed. Advertised routes are listed in the Advertised routes section.
gcloud
Use the gcloud compute routers list-bgp-routes
command:
gcloud compute routers list-bgp-routes ROUTER_NAME \
--address-family=ADDRESS_FAMILY \
--policy-applied \
--peer=PEER_NAME \
--region=REGION \
--route-direction=ROUTE_DIRECTION
Replace the following:
ADDRESS_FAMILY
: the IP address family to display routes for:IPV4
: for IPv4-based BGP addressesIPV6
: for IPv6-based BGP addresses
PEER_NAME
: the name of the BGP peerROUTE_DIRECTION
: the direction to display routes for:INBOUND
: routes learned from the BGP peerOUTBOUND
: routes advertised to the BGP peer
The output is similar to the following:
--- asPaths: - asns: - 64515 type: AS_PATH_TYPE_SEQUENCE communities: - 65535:65281 destination: prefix: 192.168.1.0/24 med: 100 origin: BGP_ORIGIN_INCOMPLETE --- asPaths: - asns: - 64515 type: AS_PATH_TYPE_SEQUENCE communities: - 65535:65281 destination: prefix: 192.168.2.0/24 med: 333 origin: BGP_ORIGIN_INCOMPLETE
API
Use the routers.listBgpRoutes
method:
GET https://compute.googleapis.com/compute/projects/PROJECT_ID/regions/REGION/routers/ROUTER_NAME/listBgpRoutes { "addressFamily": "ADDRESS_FAMILY", "peer": "PEER_NAME", "policyApplied": TRUE, "routeType": "ROUTE_TYPE" }
Replace the following:
PROJECT_ID
: the project that contains your Cloud RouterREGION
: the region in which your Cloud Router is locatedROUTER_NAME
: the name of your Cloud RouterADDRESS_FAMILY
: the IP address family to display routes for:IPV4
: for IPv4-based BGP addressesIPV6
: for IPv6-based BGP addresses
PEER_NAME
: the name of the BGP peerROUTE_TYPE
: the type of route to display:LEARNED
: route learned from the BGP peerADVERTISED
: route advertised to the BGP peer
The output is similar to the following:
{
"kind": "compute#routersListBgpRoutes",
"result": [
{
"destination": {
"prefix": "10.0.1.0/24"
},
"asPaths": [
{
"type": "AS_PATH_TYPE_SEQUENCE",
"asns": [
64514
]
}
],
"origin": "BGP_ORIGIN_INCOMPLETE",
"med": 100
},
{
"destination": {
"prefix": "10.0.2.0/24"
},
"asPaths": [
{
"type": "AS_PATH_TYPE_SEQUENCE",
"asns": [
64514
]
}
],
"origin": "BGP_ORIGIN_INCOMPLETE",
"med": 338
}
]
}
Check the best dynamic routes
Check the best dynamic routes per Cloud Router and per region per VPC:
gcloud
Use the gcloud compute routers get-status
command:
gcloud compute routers get-status ROUTER_NAME \
--region=REGION
The output includes the following information:
bestRoutesForRouter
: represents the best routes for a specific Cloud RouterbestRoutes
: represents the best routes per region of a Cloud Router of that VPC.
The output is similar to the following for bestRoutesForRouter
:
bestRoutesForRouter:
- asPaths:
- asLists:
- 65002
pathSegmentType: AS_SEQUENCE
creationTimestamp: '2024-09-26T18:28:54.346-07:00'
destRange: 192.168.1.0/24
kind: compute#route
network: https://www.googleapis.com/compute/projects/PROJECT_ID/global/networks/NETWORK_NAME
nextHopIp: 169.254.0.2
nextHopOrigin: INCOMPLETE
nextHopVpnTunnel: https://www.googleapis.com/compute/projects/PROJECT_ID/regions/REGION/vpnTunnels/vpc-demo-tunnel0
priority: 100
routeStatus: ACTIVE
routeType: BGP
- asPaths:
- asLists:
- 65002
pathSegmentType: AS_SEQUENCE
creationTimestamp: '2024-09-27T12:44:56.575-07:00'
destRange: 192.168.1.0/24
kind: compute#route
network: https://www.googleapis.com/compute/projects/PROJECT_ID/global/networks/NETWORK_NAME
nextHopIp: 169.254.1.2
nextHopOrigin: INCOMPLETE
nextHopVpnTunnel: https://www.googleapis.com/compute/projects/PROJECT_ID/regions/REGION/vpnTunnels/vpc-demo-tunnel1
priority: 100
routeStatus: ACTIVE
routeType: BGP
The output is similar to the following for bestRoutes
:
bestRoutes:
- asPaths:
- asLists:
- 65002
pathSegmentType: AS_SEQUENCE
creationTimestamp: '2024-09-26T18:33:50.505-07:00'
destRange: 192.168.1.0/24
kind: compute#route
network: https://www.googleapis.com/compute/projects/PROJECT_ID/global/networks/NETWORK_NAME
nextHopIp: 169.254.0.2
nextHopOrigin: INCOMPLETE
nextHopVpnTunnel: https://www.googleapis.com/compute/projects/PROJECT_ID/regions/REGION/vpnTunnels/vpc-demo-tunnel0
priority: 100
routeType: BGP
- asPaths:
- asLists:
- 65002
pathSegmentType: AS_SEQUENCE
creationTimestamp: '2024-09-27T12:46:49.028-07:00'
destRange: 192.168.1.0/24
kind: compute#route
network: https://www.googleapis.com/compute/projects/PROJECT_ID/global/networks/NETWORK_NAME
nextHopIp: 169.254.1.2
nextHopOrigin: INCOMPLETE
nextHopVpnTunnel: https://www.googleapis.com/compute/projects/PROJECT_ID/regions/REGION/vpnTunnels/vpc-demo-tunnel1
priority: 100
routeType: BGP
The output includes the following values:
PROJECT_ID
: the project that contains your Cloud RouterNETWORK_NAME
: the name of the VPC networkREGION
: the name of the region
API
Use the routers.getRouterStatus
method:
GET https://compute.googleapis.com/compute/projects/PROJECT_ID/regions/REGION/routers/ROUTER_NAME/getRouterStatus
Replace the following:
PROJECT_ID
: the project that contains your Cloud RouterREGION
: the region in which your Cloud Router is locatedROUTER_NAME
: the name of your Cloud Router
The output includes the following information:
bestRoutes
: represents the best routes per region of a Cloud Router of that VPC.bestRoutesForRouter
: represents the best routes for a specific Cloud Router
The output is similar to the following for bestRoutes
:
"bestRoutes": [
{
"kind": "compute#route",
"creationTimestamp": "2025-03-05T11:20:40.323-08:00",
"network": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/networks/NETWORK_NAME",
"destRange": "200.0.0.0/24",
"priority": 100,
"nextHopIp": "169.254.0.1",
"nextHopVpnTunnel": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/vpnTunnels/TUNNEL_NAME",
"routeType": "BGP",
"asPaths": [
{
"pathSegmentType": "AS_SEQUENCE",
"asLists": [
65001
]
}
],
"nextHopOrigin": "INCOMPLETE"
},
The output is similar to the following for bestRoutesForRouter
:
"bestRoutesForRouter": [
{
"kind": "compute#route",
"creationTimestamp": "2025-03-05T11:20:50.240-08:00",
"network": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/networks/NETWORK_NAME",
"destRange": "10.2.1.0/24",
"priority": 100,
"nextHopIp": "169.254.0.1",
"nextHopVpnTunnel": "https://www.googleapis.com/compute/v1/projects/PROJECT_NAME/regions/REGION/vpnTunnels/TUNNEL_NAME",
"routeType": "BGP",
"asPaths": [
{
"pathSegmentType": "AS_SEQUENCE",
"asLists": [
65001
]
}
],
"routeStatus": "ACTIVE",
"nextHopOrigin": "INCOMPLETE"
},
{
"kind": "compute#route",
"creationTimestamp": "2025-03-05T01:50:01.725-08:00",
"network": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/networks/on-prem",
"destRange": "200.0.0.0/24",
"priority": 100,
"nextHopIp": "169.254.0.1",
"nextHopVpnTunnel": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/vpnTunnels/TUNNEL_NAME",
"routeType": "BGP",
"asPaths": [
{
"pathSegmentType": "AS_SEQUENCE",
"asLists": [
65001
]
}
],
"routeStatus": "ACTIVE",
"nextHopOrigin": "INCOMPLETE"
},
{
"kind": "compute#route",
"creationTimestamp": "2025-03-06T05:30:06.277-08:00",
"network": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/networks/on-prem",
"destRange": "10.2.1.0/24",
"priority": 100,
"nextHopIp": "169.254.1.1",
"nextHopVpnTunnel": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/vpnTunnels/TUNNEL_NAME",
"routeType": "BGP",
"asPaths": [
{
"pathSegmentType": "AS_SEQUENCE",
"asLists": [
65001
]
}
],
"routeStatus": "ACTIVE",
"nextHopOrigin": "INCOMPLETE"
}
],
The output includes the following values:
PROJECT_ID
: the project that contains your Cloud RouterREGION
: the region in which your Cloud Router is locatedROUTER_NAME
: the name of your Cloud RouterTUNNEL_NAME
: if applicable, the name of your VPN tunnel
View the VPC forwarding plane route table
Do the following:
In the Google Cloud console, go to the Routes page.
On the Effective routes tab, select the network you want to list routes for.
In the Region list, select the region that you want to list routes in, and then click View.