gcloud alpha compute routes create Stay organized with collections Save and categorize content based on your preferences.
- NAME
- gcloud alpha compute routes create - create a new route
- SYNOPSIS
gcloud alpha compute routes createNAME--destination-range=DESTINATION_RANGE(--next-hop-address=NEXT_HOP_ADDRESS|--next-hop-gateway=NEXT_HOP_GATEWAY|--next-hop-ilb=NEXT_HOP_ILB|--next-hop-instance=NEXT_HOP_INSTANCE|--next-hop-vpn-tunnel=NEXT_HOP_VPN_TUNNEL)[--description=DESCRIPTION][--network=NETWORK; default="default"][--next-hop-ilb-region=NEXT_HOP_ILB_REGION][--next-hop-instance-zone=NEXT_HOP_INSTANCE_ZONE][--next-hop-vpn-tunnel-region=NEXT_HOP_VPN_TUNNEL_REGION][--priority=PRIORITY; default=1000][--resource-manager-tags=[KEY=VALUE,…]][--tags=TAG,[TAG,…]][GCLOUD_WIDE_FLAG …]
- DESCRIPTION
(ALPHA)gcloud alpha compute routes createis used tocreate routes. A route is a rule that specifies how certain packets should behandled by the virtual network. Routes are associated with virtual machineinstances by tag, and the set of routes for a particular VM is called itsrouting table. For each packet leaving a virtual machine, the system searchesthat machine's routing table for a single best matching route.Routes match packets by destination IP address, preferring smaller or morespecific ranges over larger ones (see
). If there is a tie,the system selects the route with the smallest priority value. If there is stilla tie, it uses the layer 3 and 4 packet headers to select just one of theremaining matching routes. The packet is then forwarded as specified by--destination-range,--next-hop-address,--next-hop-instance,--next-hop-vpn-tunnel, or--next-hop-gatewayof the winning route.Packets that do not match any route in the sending virtual machine routing tablewill be dropped.--next-hop-ilbExactly one of
,--next-hop-address,--next-hop-gateway,--next-hop-vpn-tunnel, or--next-hop-instancemust be provided with thiscommand.--next-hop-ilb- EXAMPLES
- To create a route with the name 'route-name' with destination range '0.0.0.0/0'and with next hop gateway 'default-internet-gateway', run:
gcloudalphacomputeroutescreateroute-name--destination-range=0.0.0.0/0--next-hop-gateway=default-internet-gateway - POSITIONAL ARGUMENTS
NAME- Name of the route to create.
- REQUIRED FLAGS
--destination-range=DESTINATION_RANGE- The destination range of outgoing packets that the route will apply to. To matchall traffic, use ``0.0.0.0/0´´.
- Exactly one of these must be specified:
--next-hop-address=NEXT_HOP_ADDRESS- Specifies the IP address of an instance that should handle matching packets. Theinstance must have IP forwarding enabled (i.e., include
when creating the instanceusing--can-ip-forwardgcloudcompute instances create) --next-hop-gateway=NEXT_HOP_GATEWAY- Specifies the gateway that should handle matching packets. Currently, the onlyacceptable value is
default-internet-gatewaywhich is a gatewayoperated by Google Compute Engine. --next-hop-ilb=NEXT_HOP_ILB- Specifies the name or IP address of a forwarding rule for an internal TCP/UDPload balancer. The forwarding rule's
--load-balancing-schememustbeINTERNAL. You can use any--destination-rangethatdoesn't exactly match the destination of a subnet route and isn't more specific(has a longer subnet mask) than the destination of a subnet route. For moreinformation, seehttps://cloud.google.com/load-balancing/docs/internal/ilb-next-hop-overview#destination_range. --next-hop-instance=NEXT_HOP_INSTANCE- Specifies the name of an instance that should handle traffic matching thisroute. When this flag is specified, the zone of the instance must be specifiedusing
.--next-hop-instance-zone --next-hop-vpn-tunnel=NEXT_HOP_VPN_TUNNEL- The target VPN tunnel that will receive forwarded traffic.
- OPTIONAL FLAGS
--description=DESCRIPTION- An optional, textual description for the route.
--network=NETWORK; default="default"- Specifies the network to which the route will be applied.
--next-hop-ilb-region=NEXT_HOP_ILB_REGION- The region of the next hop forwarding rule. If not specified, you might beprompted to select a region (interactive mode only).
To avoid prompting when this flag is omitted, you can set the
property:compute/regiongcloudconfigsetcompute/regionREGIONA list of regions can be fetched by running:
gcloudcomputeregionslistTo unset the property, run:
gcloudconfigunsetcompute/regionAlternatively, the region can be stored in the environment variable
.CLOUDSDK_COMPUTE_REGION --next-hop-instance-zone=NEXT_HOP_INSTANCE_ZONE- The zone of the next hop instance. If not specified, you might be prompted toselect a zone (interactive mode only).
gcloudattempts to identify theappropriate zone by searching for resources in your currently active project. Ifthe zone cannot be determined,gcloudprompts you for a selection withall available Google Cloud Platform zones.To avoid prompting when this flag is omitted, the user can set the
property:compute/zonegcloudconfigsetcompute/zoneZONEA list of zones can be fetched by running:
gcloudcomputezoneslistTo unset the property, run:
gcloudconfigunsetcompute/zoneAlternatively, the zone can be stored in the environment variable
.CLOUDSDK_COMPUTE_ZONE --next-hop-vpn-tunnel-region=NEXT_HOP_VPN_TUNNEL_REGION- The region of the next hop vpn tunnel. If not specified, you might be promptedto select a region (interactive mode only).
To avoid prompting when this flag is omitted, you can set the
property:compute/regiongcloudconfigsetcompute/regionREGIONA list of regions can be fetched by running:
gcloudcomputeregionslistTo unset the property, run:
gcloudconfigunsetcompute/regionAlternatively, the region can be stored in the environment variable
.CLOUDSDK_COMPUTE_REGION --priority=PRIORITY; default=1000- Specifies the priority of this route relative to other routes with the samespecificity. The lower the value, the higher the priority.
--resource-manager-tags=[KEY=VALUE,…]- A comma-separated list of Resource Manager tags to apply to the route.
--tags=TAG,[TAG,…]- Identifies the set of instances that this route will apply to. If no tags areprovided, the route will apply to all instances in the network.
- GCLOUD WIDE FLAGS
- These flags are available to all commands:
--access-token-file,--account,--billing-project,--configuration,--flags-file,--flatten,--format,--help,--impersonate-service-account,--log-http,--project,--quiet,--trace-token,--user-output-enabled,--verbosity.Run
$gcloud helpfor details. - NOTES
- This command is currently in alpha and might change without notice. If thiscommand fails with API permission errors despite specifying the correct project,you might be trying to access an API with an invitation-only early accessallowlist. These variants are also available:
gcloudcomputeroutescreategcloudbetacomputeroutescreate
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 2025-05-13 UTC.