Set routing and best path selection modes
The following Virtual Private Cloud (VPC) network settings control how all Cloud Routers work within the network:
-
Advertised routes are controlled by the dynamic routing mode of the VPC network.
-
Learned routes are controlled by both the dynamic routing mode and the best path selection mode of the VPC network.
The dynamic routing mode of a VPC network is either regional (default) or global .
The best path selection mode of a VPC network is either legacy (default) or standard . As a best practice, we recommend using legacy best path selection mode for critical workloads.
For more information about best path selection modes, see Best path selection .
You can specify the dynamic routing mode and the best path selection mode when you create a VPC network, or when you update a VPC network.
View a VPC network's dynamic routing and best path selection modes
To view the current dynamic routing mode and best path selection mode of a VPC network, follow these steps.
Console
-
In the Google Cloud console, go to the VPC networkspage.
-
To view a network's details page, click the network's name.
-
In the Dynamic routing modesection, the value indicates the type of dynamic routing mode, either Regionalor Global.
-
In the * Best path selection modesection, the value indicates the type of best path selection mode, either Standardor Legacy.
gcloud
Run the gcloud compute networks describe
command
:
gcloud compute networks describe NETWORK_NAME \ --format = "get(routingConfig)" \ --project = PROJECT_ID
Replace the following:
-
NETWORK_NAME
: the name of the VPC network -
PROJECT_ID
: the ID of the project that contains the VPC network
In the output, see the following:
-
The
routingMode
is the dynamic routing mode of the VPC network. Its value is eitherREGIONAL
orGLOBAL
. -
The
bgpBestPathSelectionMode
is the best path selection mode of the VPC network. Its value is eitherLEGACY
orSTANDARD
. -
If the best path selection mode (
bgpBestPathSelectionMode
) isSTANDARD
, the output might contain the following additional items: -
bgpAlwaysCompareMed
: Values are eitherTrue
orFalse
. IfbgpAlwaysCompareMed
isn't included in the output, the implied default value isFalse
. -
bgpInterRegionCost
: Values are eitherDEFAULT
orADD_COST_TO_MED
. IfbgpInterRegionCost
isn't included in the output, the implied default value isDEFAULT
.
API
Use the networks.get
method
:
GET https://compute.googleapis.com/compute/v1/projects/ PROJECT_ID /global/networks/ NETWORK_NAME
Replace the following:
-
PROJECT_ID
: the ID of the project that contains the VPC network -
NETWORK_NAME
: the name of the VPC network
In the output, see the following:
-
routingMode
is the dynamic routing mode of the VPC network. Its value is eitherREGIONAL
orGLOBAL
. -
bgpBestPathSelectionMode
is the best path selection mode of the VPC network. Its value is eitherLEGACY
orSTANDARD
. -
If the best path selection mode,
bgpBestPathSelectionMode
, isSTANDARD
, the output might contain the following additional items: -
bgpAlwaysCompareMed
: Values are eitherTrue
orFalse
. IfbgpAlwaysCompareMed
isn't included in the output, the implied default value isFalse
. -
bgpInterRegionCost
: Values are eitherDEFAULT
orADD_COST_TO_MED
. IfbgpInterRegionCost
isn't included in the output, the implied default value isDEFAULT
.
Change a VPC network's dynamic routing and best path selection modes
To change either the current dynamic routing mode, best path selection mode, or both of a VPC network, follow these steps.
Console
-
In the Google Cloud console, go to the VPC networkspage.
-
To view a network's details page, click the network's name.
-
To modify the network, click Edit.
-
In the Dynamic routing modesection, select Regionalor Global.
-
In the Best path selection modesection, select Legacyor Standard.
If you select standard best path selection mode, then you can do the following:
-
Choose if Always compare MEDis enabled:
-
If selected, always compares MED values without considering ASN values.
-
If not selected, compares MED values within each neighbor's ASN values.
-
-
For Inter region cost, you can select the following:
-
Default: doesn't add inter-region costs to MED values.
-
Add cost to MED: adds inter-region costs to MED values.
-
-
-
To confirm, click Save.
gcloud
To set the dynamic routing and best path selection modes when creating a
new VPC network, use the gcloud compute networks
create
command
:
gcloud compute networks create NETWORK_NAME \ --bgp-routing-mode = DYNAMIC_ROUTING_MODE \ --bgp-best-path-selection-mode = BEST_PATH_SELECTION_MODE \ --project = PROJECT_ID
To change the dynamic routing and best path selection modes for an existing
VPC network, use the gcloud compute networks
update
command
:
gcloud compute networks update NETWORK_NAME \ --bgp-routing-mode = DYNAMIC_ROUTING_MODE \ --bgp-best-path-selection-mode = BEST_PATH_SELECTION_MODE \ --project = PROJECT_ID
If you set --bgp-best-path-selection-mode=STANDARD
, you can also use the --bgp-bps-always-compare-med
, --no-bgp-bps-always-compare-med
, or --bgp-bps-inter-region-cost
flag. In the following example, you specify
either create
or update
:
gcloud compute networks { create | update } NETWORK_NAME \ --bgp-routing-mode = DYNAMIC_ROUTING_MODE \ --bgp-best-path-selection-mode = STANDARD \ -- [ no- ] bgp-bps-always-compare-med \ --bgp-bps-inter-region-cost = COST_MODE \ --project = PROJECT_ID
Replace the following:
-
NETWORK_NAME
: the name of the VPC network to modify -
DYNAMIC_ROUTING_MODE
: the dynamic routing mode to use—specifyREGIONAL
orGLOBAL
. The default value isREGIONAL
. -
BEST_PATH_SELECTION_MODE
: the best path selection mode to use—specifyLEGACY
orSTANDARD
. The default value isLEGACY
. - The following are only applicable when using
STANDARD
best path selection mode. These flags must be omitted if you useLEGACY
best path selection mode. -
--bgp-bps-always-compare-med
: use this flag to always compare MED without considering the neighbor ASN values. -
--no-bgp-bps-always-compare-med
: use this flag to conditionally compare MED values within each neighbor ASN. -
COST_MODE
: controls whether an inter-region cost is added to the received MED value—specifyDEFAULT
orADD-COST-TO-MED
.-
DEFAULT
doesn't add inter-region costs to MED values. -
ADD-COST-TO-MED
adds inter-region costs to MED values.
-
API
To set the dynamic routing and best path selection modes when creating a new
VPC network, use the networks.insert
method
:
POST https://compute.googleapis.com/compute/v1/projects/ PROJECT_ID /global/networks/ NETWORK_NAME { "routingConfig": { "routingMode": " DYNAMIC_ROUTING_MODE " "bgpBestPathSelectionMode": " BEST_PATH_SELECTION_MODE " "bgpAlwaysCompareMed": True | False "bgpInterRegionCost": " COST " } }
To change the dynamic routing and best path selection modes for an existing
VPC network, use the networks.patch
method
:
PATCH https://compute.googleapis.com/compute/v1/projects/ PROJECT_ID /global/networks/ NETWORK_NAME { "routingConfig": { "routingMode": " DYNAMIC_ROUTING_MODE " "bgpBestPathSelectionMode": " BEST_PATH_SELECTION_MODE " "bgpAlwaysCompareMed": True | False "bgpInterRegionCost": " COST " } }
Replace the following:
-
PROJECT_ID
: the ID of the project that contains the VPC network to modify -
NETWORK_NAME
: the name of the VPC network to modify -
DYNAMIC_ROUTING_MODE
: the dynamic routing mode to use—specifyREGIONAL
orGLOBAL
. The default value isREGIONAL
. -
BEST_PATH_SELECTION_MODE
: the best path selection mode to use—specifyLEGACY
orSTANDARD
. The default value isLEGACY
. -
COST
: controls whether an inter-region cost is added to the received MED value—specifyDEFAULT
orADD-COST-TO-MED
. -
DEFAULT
does not add inter-region costs to MED values. -
ADD-COST-TO-MED
adds inter-region costs to MED values.
When bgpAlwaysCompareMed
is True
, always compare MED without considering
the neighbor ASN values. When False
, conditionally compare MED values
within each neighbor ASN. The default is False
. bgpAlwaysCompareMed
is
optional when bgpBestPathSelectionMode
is STANDARD
but must be
omitted when bgpBestPathSelectionMode
is LEGACY
.
When bgpBestPathSelectionMode
is STANDARD
, bgpInterRegionCost
is
optional but must be omitted when bgpBestPathSelectionMode
is LEGACY
.