This page shows you how to configure static routes for Network Connectivity Center. If you aren't familiar with static routes, see the Static routes overview.
When you select the IP address of the internal passthrough Network Load Balancer, its
forwarding rule's --load-balancing-scheme must be INTERNAL.
You can use any --destination-range that meets the following criteria:
- The
--destination-rangedoesn't exactly match the destination of a subnet route. - The
--destination-rangedoesn't have a longer subnet mask than the destination of a subnet route.
For more information about destination range requirements, see destination IP address range.
Create static routes
You can create static routes for Network Connectivity Center spokes by using the
gcloud compute routes create
command. The following example
shows you how to create a static route for a
Network Connectivity Center spoke:
gcloud compute routes create ROUTE_NAME \
--network=HOME_VPC \
--destination-range=DESTINATION_RANGE \
--priority=PRIORITY \
--next-hop-ilb=FORWARDING_RULE
Replace the following:
ROUTE_NAME: the name of the route.HOME_VPC: the name of the VPC network that contains the route.DESTINATION_RANGE: the destination IPv4 addresses to which this route applies. The broadest possible destination is0.0.0.0/0.PRIORITY: the route priority, which can be from0(the highest priority) to65535(the lowest priority). For more information about route priority, see Routing order.FORWARDING_RULE: IP address of a forwarding rule for an internal passthrough Network Load Balancer.
The following sections demonstrate two use cases, highlighting the differences in how you create static routes for mesh and star topologies.
Create static routes in a mesh topology
For this example, assume that you have two spoke VPCs,
vpc-1 and vpc-2, which are connected to the same Network Connectivity Center hub.
Suppose that you also have a transit VPC transit that is
connected to vpc-2 through a network virtual appliance (NVA). You want to
reach the transit VPC from the vpc-1 and vpc-2 spokes, so
you configure static routes using the following steps:
First, create a static route in spoke
vpc-1with thetransitVPC's IP address as the destination, andvpc-2's internal passthrough Network Load Balancer IP address as the next hop:gcloud compute routes create ROUTE_NAME \ --network=vpc-1 \ --destination-range=DESTINATION_RANGE \ --priority=PRIORITY \ --next-hop-ilb=FORWARDING_RULEReplace the following:
ROUTE_NAME: the name of the routeDESTINATION_RANGE: the destination IPv4 addresses for thetransitVPC.PRIORITY: the route priority, which can be from0(the highest priority) to65535(the lowest priority). For more information about route priority, see Routing order.FORWARDING_RULE: IP address of a forwarding rule for a internal passthrough Network Load Balancer invpc-2.
Create a static route in spoke
vpc-2with thetransitVPC's IP address as the destination, and thetransitVPC's internal passthrough Network Load Balancer IP address as the next hop:gcloud compute routes create ROUTE_NAME \ --network=vpc-2 \ --destination-range=DESTINATION_RANGE \ --priority=PRIORITY \ --next-hop-ilb=FORWARDING_RULEReplace the following:
ROUTE_NAME: the name of the routeDESTINATION_RANGE: the destination IPv4 addresses for thetransitVPCPRIORITY: the route priority, which can be from0(the highest priority) to65535(the lowest priority); for more information about route priority, see Routing order.FORWARDING_RULE: IP address of a forwarding rule for an internal passthrough Network Load Balancer in thetransitVPC
Create a return route in the
transitVPC tovpc-2, withvpc-2's IP address as the destination, andvpc-2's internal passthrough Network Load Balancer IP address as the next hop:gcloud compute routes create ROUTE_NAME \ --network=transit \ --destination-range=DESTINATION_RANGE \ --priority=PRIORITY \ --next-hop-ilb=FORWARDING_RULEReplace the following:
ROUTE_NAME: the name of the routeDESTINATION_RANGE: the destination IPv4 address forvpc-2PRIORITY: the route priority, which can be from0(the highest priority) to65535(the lowest priority); for more information about route priority, see Routing order.FORWARDING_RULE: IP address of a forwarding rule for an internal passthrough Network Load Balancer invpc-2
Next, create a return route in the
transitVPC tovpc-1, withvpc-1's IP address as the destination, andvpc-2's internal passthrough Network Load Balancer IP address as the next hop:gcloud compute routes create ROUTE_NAME \ --network=transit \ --destination-range=DESTINATION_RANGE \ --priority=PRIORITY \ --next-hop-ilb=FORWARDING_RULEReplace the following:
ROUTE_NAME: the name of the routeDESTINATION_RANGE: the destination IPv4 addresses forvpc-2PRIORITY: the route priority, which can be from0(the highest priority) to65535(the lowest priority); for more information about route priority, see Routing order.FORWARDING_RULE: IP address of a forwarding rule for an internal passthrough Network Load Balancer invpc-2
Finally, create a return route in
vpc-2tovpc-1, withvpc-1's IP address as the destination, andvpc-1's internal passthrough Network Load Balancer IP address as the next hop:gcloud compute routes create ROUTE_NAME \ --network=vpc-2 \ --destination-range=DESTINATION_RANGE \ --priority=PRIORITY \ --next-hop-ilb=FORWARDING_RULEReplace the following:
ROUTE_NAME: the name of the routeDESTINATION_RANGE: the destination IPv4 addresses forvpc-1PRIORITY: the route priority, which can be from0(the highest priority) to65535(the lowest priority); for more information about route priority, see Routing order.FORWARDING_RULE: IP address of a forwarding rule for a internal passthrough Network Load Balancer invpc-1
For more information about NVAs, see Network virtual appliances.
Create static routes in a star topology
For this example, assume that you have two edge VPCs,
edge-1 and edge-2 that are connected to center VPC center.
Suppose that you also have a transit VPC transit that is connected to center
through a network virtual appliance (NVA). You want to reach the transit
VPC from edge-1, so you configure static routes using the
following steps:
First, create a static route in
edge-1with thetransitVPC's IP address as the destination, andcenter's internal passthrough Network Load Balancer IP address as the next hop:gcloud compute routes create ROUTE_NAME \ --network=edge-1 \ --destination-range=DESTINATION_RANGE \ --priority=PRIORITY \ --next-hop-ilb=FORWARDING_RULEReplace the following:
ROUTE_NAME: the name of the routeDESTINATION_RANGE: the destination IPv4 addresses for thetransitVPCPRIORITY: the route priority, which can be from0(the highest priority) to65535(the lowest priority); for more information about route priority, see Routing order.FORWARDING_RULE: IP address of a forwarding rule for an internal passthrough Network Load Balancer incenter
Create a static route in
centerwith thetransitVPC's IP address as the destination, and thetransitVPC's internal passthrough Network Load Balancer IP address as the next hop:gcloud compute routes create ROUTE_NAME \ --network=vpc-1 \ --destination-range=DESTINATION_RANGE \ --priority=PRIORITY \ --next-hop-ilb=FORWARDING_RULEReplace the following:
ROUTE_NAME: the name of the routeDESTINATION_RANGE: the destination IPv4 addresses for thetransitVPCPRIORITY: the route priority, which can be from0(the highest priority) to65535(the lowest priority); for more information about route priority, see Routing order.FORWARDING_RULE: IP address of a forwarding rule for an internal passthrough Network Load Balancer in thetransitVPC
Create a return route in the
transitVPC tocenter, withcenter's IP address as the destination, andcenter's internal passthrough Network Load Balancer IP address as the next hop:gcloud compute routes create ROUTE_NAME \ --network=transit \ --destination-range=DESTINATION_RANGE \ --priority=PRIORITY \ --next-hop-ilb=FORWARDING_RULEReplace the following:
ROUTE_NAME: the name of the routeDESTINATION_RANGE: the destination IPv4 addresses forcenterPRIORITY: the route priority, which can be from0(the highest priority) to65535(the lowest priority); for more information about route priority, see Routing order.FORWARDING_RULE: IP address of a forwarding rule for an internal passthrough Network Load Balancer incenter
Next, create a return route in the
transitVPC toedge-1, withedge-1's IP address as the destination, andcenter's internal passthrough Network Load Balancer IP address as the next hop:gcloud compute routes create ROUTE_NAME \ --network=transit \ --destination-range=DESTINATION_RANGE \ --priority=PRIORITY \ --next-hop-ilb=FORWARDING_RULEReplace the following:
ROUTE_NAME: the name of the routeDESTINATION_RANGE: the destination IPv4 addresses foredge-1PRIORITY: the route priority, which can be from0(the highest priority) to65535(the lowest priority); for more information about route priority, see Routing order.FORWARDING_RULE: IP address of a forwarding rule for an internal passthrough Network Load Balancer incenter
Next, create a return route in
centertoedge-1, withedge-1's IP address as the destination, andedge-1's internal passthrough Network Load Balancer IP address as the next hop:gcloud compute routes create ROUTE_NAME \ --network=center \ --destination-range=DESTINATION_RANGE \ --priority=PRIORITY \ --next-hop-ilb=FORWARDING_RULEReplace the following:
ROUTE_NAME: the name of the routeDESTINATION_RANGE: the destination IPv4 addresses foredge-1PRIORITY: the route priority, which can be from0(the highest priority) to65535(the lowest priority); for more information about route priority, see Routing order.FORWARDING_RULE: IP address of a forwarding rule for an internal passthrough Network Load Balancer inedge-1
Delete static routes
Use the following
gcloud compute routes delete
command to delete a static route,
replacingROUTE_NAME with
the name of the route:
gcloud compute routes delete ROUTE_NAME