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-range
doesn't exactly match the destination of a subnet route. - The
--destination-range
doesn'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=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-1
with thetransit
VPC'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=DESTINATION_RANGE \ --priority=PRIORITY \ --next-hop-ilb=FORWARDING_RULE
Replace the following:
ROUTE_NAME
: the name of the routeDESTINATION_RANGE
: the destination IPv4 addresses for thetransit
VPC.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-2
with thetransit
VPC's IP address as the destination, and thetransit
VPC's internal passthrough Network Load Balancer IP address as the next hop:gcloud compute routes create ROUTE_NAME \ --network=vpc-2 \ --destination=DESTINATION_RANGE \ --priority=PRIORITY \ --next-hop-ilb=FORWARDING_RULE
Replace the following:
ROUTE_NAME
: the name of the routeDESTINATION_RANGE
: the destination IPv4 addresses for thetransit
VPCPRIORITY
: 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 thetransit
VPC
Create a return route in the
transit
VPC 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=DESTINATION_RANGE \ --priority=PRIORITY \ --next-hop-ilb=FORWARDING_RULE
Replace the following:
ROUTE_NAME
: the name of the routeDESTINATION_RANGE
: the destination IPv4 address forvpc-2
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 invpc-2
Next, create a return route in the
transit
VPC 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=DESTINATION_RANGE \ --priority=PRIORITY \ --next-hop-ilb=FORWARDING_RULE
Replace the following:
ROUTE_NAME
: the name of the routeDESTINATION_RANGE
: the destination IPv4 addresses forvpc-2
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 invpc-2
Finally, create a return route in
vpc-2
tovpc-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=DESTINATION_RANGE \ --priority=PRIORITY \ --next-hop-ilb=FORWARDING_RULE
Replace the following:
ROUTE_NAME
: the name of the routeDESTINATION_RANGE
: the destination IPv4 addresses forvpc-1
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-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-1
with thetransit
VPC'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=DESTINATION_RANGE \ --priority=PRIORITY \ --next-hop-ilb=FORWARDING_RULE
Replace the following:
ROUTE_NAME
: the name of the routeDESTINATION_RANGE
: the destination IPv4 addresses for thetransit
VPCPRIORITY
: 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
center
with thetransit
VPC's IP address as the destination, and thetransit
VPC's internal passthrough Network Load Balancer IP address as the next hop:gcloud compute routes create ROUTE_NAME \ --network=vpc-1 \ --destination=DESTINATION_RANGE \ --priority=PRIORITY \ --next-hop-ilb=FORWARDING_RULE
Replace the following:
ROUTE_NAME
: the name of the routeDESTINATION_RANGE
: the destination IPv4 addresses for thetransit
VPCPRIORITY
: 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 thetransit
VPC
Create a return route in the
transit
VPC 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=DESTINATION_RANGE \ --priority=PRIORITY \ --next-hop-ilb=FORWARDING_RULE
Replace the following:
ROUTE_NAME
: the name of the routeDESTINATION_RANGE
: the destination IPv4 addresses forcenter
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 incenter
Next, create a return route in the
transit
VPC 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=DESTINATION_RANGE \ --priority=PRIORITY \ --next-hop-ilb=FORWARDING_RULE
Replace the following:
ROUTE_NAME
: the name of the routeDESTINATION_RANGE
: the destination IPv4 addresses foredge-1
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 incenter
Next, create a return route in
center
toedge-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=DESTINATION_RANGE \ --priority=PRIORITY \ --next-hop-ilb=FORWARDING_RULE
Replace the following:
ROUTE_NAME
: the name of the routeDESTINATION_RANGE
: the destination IPv4 addresses foredge-1
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 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