Create BGP route policies

This guide describes how to create BGP route policies in Cloud Router.

You can create BGP route policies for Cloud Router using any of the following:

The examples on this page create a BGP route policy to set the BGP multiple exit discriminator (MED) attribute value to 12345 for BGP routes that aren't included in

Upload a BGP route policy

  1. Create the BGP route policy in your preferred text editor. You can use JSON or YAML formatting to create your BGP route policy. The following example uses a YAML file:

    # Modify the MED value for the BGP routes that aren't in the range
    - priority: 1
        expression: >
          destination != ''
      - expression: med.set(12345)

    Replace the following:

    • BGP_ROUTE_POLICY_NAME: a name for the BGP route policy.
    • ROUTE_POLICY_TYPE: the type of BGP route policy you're creating. The type can be one of the following:

      • ROUTE_POLICY_TYPE_IMPORT: BGP route policies for inbound routes.
      • ROUTE_POLICY_TYPE_EXPORT: BGP route policies for outbound routes.
  2. Upload the BGP route policy:

    gcloud beta compute routers upload-route-policy ROUTER_NAME \
        --region=REGION \
        --policy-name=BGP_ROUTE_POLICY_NAME \
        --file-name=FILE_NAME \

    Replace the following:

    • ROUTER_NAME: the name of the Cloud Router
    • REGION: the region the Cloud Router is in
    • FILENAME: the filename that you're uploading
  3. Apply the BGP route policies to BGP peers:

    gcloud beta compute routers update-bgp-peer ROUTER_NAME \
        --region=REGION \
        --peer-name=PEER_NAME \

    Replace the following:

    • PEER_NAME: the BGP peer's name to apply the BGP route policy to.
    • IMPORT_POLICIES: a comma-separated list of import policies. Passing an empty string removes all import policies.

What's next