Configure the BGP identifier range for a Cloud Router
Each Cloud Router has a BGP identifier, also known as a router ID . The BGP identifier is unique to each Cloud Router in your Virtual Private Cloud (VPC) network as required by RFC 6286 .
By default, the BGP identifier is automatically assigned, but you can configure your Cloud Router with an explicit BGP identifier range . If you choose to assign your own BGP identifier range, your Cloud Router is assigned a stable BGP identifier within your selected range.
If you don't configure a BGP identifier range, Cloud Router assigns a BGP identifier based on the last-sorted BGP IPv4 address from among its BGP sessions, sorted lexicographically. Similarly, when you add the first IPv6 interface to a Cloud Router that isn't configured with a BGP identifier range, Cloud Router assigns a BGP identifier based on the last-sorted BGP IPv6 address range from among its BGP peers, sorted lexicographically.
BGP identifier changes and BGP session restarts
Unless you've configured an explicit BGP identifier range, Cloud Router might change the automatically generated router ID in the following circumstances:
- You add a BGP session
- You remove a BGP session
- During periodic maintenance
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 .
Assign a BGP identifier range to Cloud Router
This section describes how to assign an explicit BGP identifier range to a Cloud Router.
Console
-
In the Google Cloud console, go to the Create a Cloud Router page.
-
Specify the Cloud Router's details:
- Name
: The name of the Cloud Router. This name is
displayed in the Google Cloud console and is used by the
Google Cloud CLI to reference the Cloud Router—for
example,
my-router
. - Description : Optional. A description of the Cloud Router.
- Network
: The VPC network that contains
the instances that you want to reach—for example,
my-network
. - Region
: The region where you want to locate the
Cloud Router—for example,
asia-east1
. -
Google ASN : Any private ASN (
64512
-65534
,4200000000
-4294967294
) that you aren't already using in the on-premises network. Cloud Router requires that you use a private ASN, but your on-premises ASN can be public or private. - BGP peer keepalive interval : The interval between two successive BGP keepalive messages that are sent to the peer router. This value must be an integer between 20 and 60 that specifies the number of seconds for the interval. The default is 20 seconds. For more information, see Manage BGP timers .
-
BGP identifier : Optional. The BGP identifier, sometimes called a router ID , that uniquely identifies a Cloud Router in a network. If omitted, Cloud Routers with IPv4 BGP sessions use one of the IPv4 BGP addresses as the BGP identifier, and adding the first IPv6 interface to this Cloud Router populates the field automatically.
For more information, see Configure the BGP identifier range for a Cloud Router .
- Optional: To specify custom advertised routes, go to the Advertised routes
section. For more information, see Advertised routes
.
- To specify custom Routes , select Create custom routes .
- Choose whether to advertise the subnets visible to the Cloud Router. Enabling this option mimics the Cloud Router's default behavior.
- To add an advertised route, select Add a custom route , and then configure it.
- To save your settings and create a Cloud Router, click Create . Your new Cloud Router appears on the Cloud Router listing page. To view its details and to configure a BGP session, select it.
gcloud
To assign an explicit BGP identifier range when you create the
Cloud Router, use the --bgp-identifier-range
flag.
gcloud compute routers create ROUTER_NAME \ --bgp-identifier-range= BGP_IDENTIFIER_RANGE
Replace BGP_IDENTIFIER_RANGE
with a link-local IPv4 range
from 169.254.0.0/16
with a subnet mask prefix length of at most /30
.
The IPv4 address range must not overlap either of the following:
-
The IPv4 address range used by another BGP session on this Cloud Router.
-
Any custom BGP identifier range used by another Cloud Router in the same VPC network and region.
API
Use the routers.insert
method
:
POST https://compute.googleapis.com/compute/v1/projects/ PROJECT_ID /regions/ REGION /routers/ ROUTER_NAME { "bgp": { "asn": " ASN_NUMBER ", "keepaliveInterval": KEEPALIVE_INTERVAL , "identifierRange": BGP_IDENTIFIER_RANGE }, "name": " ROUTER_NAME ", "network": " NETWORK " }
Replace BGP_IDENTIFIER_RANGE
with a link-local IPv4 range
from 169.254.0.0/16
with a subnet mask prefix length of at most /30
. The
range must not overlap with any existing IPv4 Cloud Router
interface or a BGP identifier range of a Cloud Router in the same
region.
Modify the BGP identifier range
This section describes how to modify an existing explicit BGP identifier range on a Cloud Router.
gcloud
To change the explicit BGP identifier range, run the following command.
gcloud compute routers update ROUTER_NAME \ --bgp-identifier-range= BGP_IDENTIFIER_RANGE
Replace BGP_IDENTIFIER_RANGE
with a link-local IPv4 range
from 169.254.0.0/16
with a subnet mask prefix length of at most /30
.
The IPv4 address range must not overlap either of the following:
-
The IPv4 address range used by another BGP session on this Cloud Router.
-
Any custom BGP identifier range used by another Cloud Router in the same VPC network and region.
API
Use the routers.patch
method
to update the bgp.identifierRange
field:
PATCH https://compute.googleapis.com/compute/v1/projects/ PROJECT_ID /regions/ REGION /routers/ ROUTER_NAME { "bgp": { "identifierRange": BGP_IDENTIFIER_RANGE } }
Replace BGP_IDENTIFIER_RANGE
with a link-local IPv4 range
from 169.254.0.0/16
with a subnet mask prefix length of at most /30
.
The IPv4 address range must not overlap either of the following:
-
The IPv4 address range used by another BGP session on this Cloud Router.
-
Any custom BGP identifier range used by another Cloud Router in the same VPC network and region.