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 networks page. 
- To view a network's details page, click the network's name. 
- In the Dynamic routing mode section, the value indicates the type of dynamic routing mode, either Regional or Global. 
- In the *Best path selection mode section, the value indicates the type of best path selection mode, either Standard or 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 - routingModeis the dynamic routing mode of the VPC network. Its value is either- REGIONALor- GLOBAL.
- The - bgpBestPathSelectionModeis the best path selection mode of the VPC network. Its value is either- LEGACYor- STANDARD.
- If the best path selection mode ( - bgpBestPathSelectionMode) is- STANDARD, the output might contain the following additional items:
- bgpAlwaysCompareMed: Values are either- Trueor- False. If- bgpAlwaysCompareMedisn't included in the output, the implied default value is- False.
- bgpInterRegionCost: Values are either- DEFAULTor- ADD_COST_TO_MED. If- bgpInterRegionCostisn't included in the output, the implied default value is- DEFAULT.
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:
- routingModeis the dynamic routing mode of the VPC network. Its value is either- REGIONALor- GLOBAL.
- bgpBestPathSelectionModeis the best path selection mode of the VPC network. Its value is either- LEGACYor- STANDARD.
- If the best path selection mode, - bgpBestPathSelectionMode, is- STANDARD, the output might contain the following additional items:
- bgpAlwaysCompareMed: Values are either- Trueor- False. If- bgpAlwaysCompareMedisn't included in the output, the implied default value is- False.
- bgpInterRegionCost: Values are either- DEFAULTor- ADD_COST_TO_MED. If- bgpInterRegionCostisn't included in the output, the implied default value is- DEFAULT.
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 networks page. 
- To view a network's details page, click the network's name. 
- To modify the network, click Edit. 
- In the Dynamic routing mode section, select Regional or Global. 
- In the Best path selection mode section, select Legacy or Standard. - If you select standard best path selection mode, then you can do the following: - Choose if Always compare MED is 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—specify- REGIONALor- GLOBAL. The default value is- REGIONAL.
- BEST_PATH_SELECTION_MODE: the best path selection mode to use—specify- LEGACYor- STANDARD. The default value is- LEGACY.
- The following are only applicable when using STANDARDbest path selection mode. These flags must be omitted if you useLEGACYbest 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—specify- DEFAULTor- ADD-COST-TO-MED.- DEFAULTdoesn't add inter-region costs to MED values.
- ADD-COST-TO-MEDadds 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—specify- REGIONALor- GLOBAL. The default value is- REGIONAL.
- BEST_PATH_SELECTION_MODE: the best path selection mode to use—specify- LEGACYor- STANDARD. The default value is- LEGACY.
- COST: controls whether an inter-region cost is added to the received MED value—specify- DEFAULTor- ADD-COST-TO-MED.
- DEFAULTdoes not add inter-region costs to MED values.
- ADD-COST-TO-MEDadds 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.
What's next?
- Dynamic routing mode effects on learned routes
- Create a Cloud Router to connect a VPC network to a peer network