Disable or remove BGP sessions

You can disable a BGP session temporarily or remove it entirely.Some common reasons for disabling a session are changing routerconfiguration when migrating to a different BGP peer or performingmaintenance on a BGP peer.

Before you begin

gcloud

If you want to use the command-line examples in this guide, do the following:

  1. Install or update to the latest version of theGoogle Cloud CLI.
  2. Set adefault region andzone.

API

If you want to use the API examples in this guide, set upAPI access.

Disable a BGP session

You can disable a BGP session by using the Google Cloud console, theupdate-bgp-peer command, or the API. BGP sessions are enabled by default.

If disabled, any active session with the BGP peer is shut down, and allassociated routing information is removed.

To disable a BGP session, follow these steps.

Console

  1. In the Google Cloud console, go to theCloud Routers page.

    Go to Cloud Routers

  2. Select the router that hosts the BGP session that you want to disable.
  3. On theRouter details page, select the BGP session that you to wantto disable.
  4. On theBGP session details page, clickEdit.
  5. ForBGP peer, selectDisabled.
  6. ClickSave.

gcloud

Run theupdate-bgp-peer command:

  gcloud compute routers update-bgp-peerROUTER_NAME \      --project=PROJECT_ID \      --peer-name=PEER_NAME \      --region=REGION \      --no-enabled

Replace the following:

  • ROUTER_NAME: the name of your Cloud Router
  • PROJECT_ID: the project that contains theCloud Router
  • PEER_NAME: the name of your BGP peer
  • REGION: the region where the Cloud Routeris located

API

Use therouters.patchmethod to update thebgpPeers[] field.

ThebgpPeers[] field accepts an array of BGP peers. When youPATCH thisfield, you overwrite the existing array of BGP peers with the new arrayincluded in your request.

  1. Send aGET request to get the current array of BGP peers for the router.For details, seeView BGP session configuration.

  2. Send aPATCH request with a new array of BGP peers. For each BGP peer forwhich you want to disable the BGP session, setbgpPeers[].enable toFALSE.

    PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/routers/ROUTER_NAME{  "bgpPeers": [BGP_PEERS  ]}

    Replace the following:

    • PROJECT_ID: the project that contains theCloud Router
    • REGION: the region where the Cloud Routeris located
    • ROUTER_NAME: the name of the Cloud Router
    • BGP_PEERS: the contents of the new array of BGPpeers

    The following example disables the session for the first BGP peer:

        {      "name": "peer-1",      "interfaceName": "if-peer-1",      "ipAddress": "169.254.10.1",      "peerIpAddress": "169.254.10.2",      "peerAsn": 64512,      "advertisedRoutePriority": 100,      "advertiseMode": "DEFAULT",      "advertisedGroups": [],      "advertisedIpRanges": [],"enable": "FALSE"    },    {      "name": "peer-2",      "interfaceName": "if-peer-2",      "ipAddress": "169.254.20.1",      "peerIpAddress": "169.254.20.2",      "peerAsn": 64513,      "advertisedRoutePriority": 100,      "advertiseMode": "DEFAULT",      "advertisedGroups": [],      "advertisedIpRanges": []    }

Enable a BGP session

You can enable a BGP session by using the Google Cloud console, theupdate-bgp-peer command, or the API. BGP sessions are enabled by default.

If enabled, the peer connection can be established with routing information.

To enable a BGP session, follow these steps.

Console

  1. In the Google Cloud console, go to theCloud Routers page.

    Go to Cloud Routers

  2. Select the router that hosts the BGP session that you want to enable.
  3. On theRouter details page, select the BGP session that you want to enable.
  4. On theBGP session details page, clickEdit.
  5. ForBGP peer, selectEnabled.
  6. ClickSave.

gcloud

Run theupdate-bgp-peer command:

  gcloud compute routers update-bgp-peerROUTER_NAME \      --project=PROJECT_ID \      --peer-name=PEER_NAME \      --region=REGION \      --enabled

Replace the following:

  • ROUTER_NAME: the name of your Cloud Router
  • PROJECT_ID: the project that contains theCloud Router
  • PEER_NAME: the name of your BGP peer
  • REGION: the region where the Cloud Routeris located

API

Use therouters.patchmethod to update thebgpPeers[] field.

ThebgpPeers[] field accepts an array of BGP peers. When you make aPATCHrequest with this field specified, you overwrite the existing array of BGP peerswith the new array included in your request.

  1. Send aGET request to get the current array of BGP peers for the router.For details, seeView Cloud Router details.

  2. Send aPATCH request with a new array of BGP peers. For each BGP peer forwhich you want to enable the BGP session, setbgpPeers[].enable toTRUE.

    PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/routers/ROUTER_NAME{  "bgpPeers": [BGP_PEERS  ]}

    Replace the following:

    • PROJECT_ID: the project that contains theCloud Router
    • REGION: the region where the Cloud Routeris located
    • ROUTER_NAME: the name of the Cloud Router
    • BGP_PEERS: the contents of the new array of BGPpeers

    The following example enables the session for the first BGP peer:

        {      "name": "peer-1",      "interfaceName": "if-peer-1",      "ipAddress": "169.254.10.1",      "peerIpAddress": "169.254.10.2",      "peerAsn": 64512,      "advertisedRoutePriority": 100,      "advertiseMode": "DEFAULT",      "advertisedGroups": [],      "advertisedIpRanges": [],"enable": "TRUE"    },    {      "name": "peer-2",      "interfaceName": "if-peer-2",      "ipAddress": "169.254.20.1",      "peerIpAddress": "169.254.20.2",      "peerAsn": 64513,      "advertisedRoutePriority": 100,      "advertiseMode": "DEFAULT",      "advertisedGroups": [],      "advertisedIpRanges": []    }

Remove a BGP session

If you delete the Cloud VPN tunnel or VLAN attachment associated witha BGP session, the session is automatically shut down.

You can remove BGP sessions manually by using the Google Cloud console, theremove-bgp-peer command, or the API. If you remove the BGP session, theVPN tunnel or VLAN attachment remains, but the Cloud Routerdoesn't advertise routes over them.

To remove a BGP session, follow these steps.

Console

  1. In the Google Cloud console, go to theCloud Routers page.

    Go to Cloud Routers

  2. Select the router that you want to remove a BGP session from.
  3. ForBGP sessions, select the BGP session that you want to remove.
  4. At the top of the page, clickDelete, and then confirm the deletion.

gcloud

Run theremove-bgp-peer command:

gcloud compute routers remove-bgp-peerROUTER_NAME \    --project=PROJECT_ID \    --peer-name=PEER_NAME \    --region=REGION \

Replace the following:

  • ROUTER_NAME: the name of your Cloud Router
  • PROJECT_ID: the project that contains theCloud Router
  • PEER_NAME: the name of your BGP peer
  • REGION: the region where the Cloud Routeris located

API

To remove BGP peers from a Cloud Router, use therouters.patchmethod to update thebgpPeers[] field.

ThebgpPeers[] field accepts an array of BGP peers. When youPATCHthis field, you overwrite the existing array of BGP peers with the new arrayincluded in your request.

  1. Send aGET request to get the current array of BGP peers for the router.For details, seeView Cloud Router details.

  2. Send aPATCH request with a new array of BGP peers. Use the array fromtheGET request in the previous step, and remove any BGP peers that youdo not want on the router.

    You can send an empty array to remove all BGP peers.

    PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/routers/ROUTER_NAME{  "bgpPeers": [BGP_PEERS  ]}

    Replace the following:

    • PROJECT_ID: the project that contains theCloud Router
    • REGION: the region where the Cloud Routeris located
    • ROUTER_NAME: the name of the Cloud Router
    • BGP_PEERS: the contents of the new array of BGPpeers

    The following example contains two BGP peers:

        {      "name": "peer-1",      "interfaceName": "if-peer-1",      "ipAddress": "169.254.10.1",      "peerIpAddress": "169.254.10.2",      "peerAsn": 64512,      "advertisedRoutePriority": 100,      "advertiseMode": "DEFAULT"    },    {      "name": "peer-2",      "interfaceName": "if-peer-2",      "ipAddress": "169.254.20.1",      "peerIpAddress": "169.254.20.2",      "peerAsn": 64513,      "advertisedRoutePriority": 100,      "advertiseMode": "DEFAULT"    }

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.