gcloud compute forwarding-rules set-target NAME (--backend-service=BACKEND_SERVICE | --target-grpc-proxy=TARGET_GRPC_PROXY | --target-http-proxy=TARGET_HTTP_PROXY | --target-https-proxy=TARGET_HTTPS_PROXY | --target-instance=TARGET_INSTANCE | --target-pool=TARGET_POOL | --target-ssl-proxy=TARGET_SSL_PROXY | --target-tcp-proxy=TARGET_TCP_PROXY | --target-vpn-gateway=TARGET_VPN_GATEWAY) [--load-balancing-scheme=LOAD_BALANCING_SCHEME; default="EXTERNAL"] [--network=NETWORK] [--subnet=SUBNET] [--subnet-region=SUBNET_REGION] [--target-instance-zone=TARGET_INSTANCE_ZONE] [--target-pool-region=TARGET_POOL_REGION] [--target-vpn-gateway-region=TARGET_VPN_GATEWAY_REGION] [--backend-service-region=BACKEND_SERVICE_REGION | --global-backend-service] [--global | --region=REGION] [--global-target-http-proxy | --target-http-proxy-region=TARGET_HTTP_PROXY_REGION] [--global-target-https-proxy | --target-https-proxy-region=TARGET_HTTPS_PROXY_REGION] [--global-target-tcp-proxy | --target-tcp-proxy-region=TARGET_TCP_PROXY_REGION] [GCLOUD_WIDE_FLAG …]
gcloud compute forwarding-rules set-target is used to set a new
target for a forwarding rule. A forwarding rule directs traffic that matches a
destination IP address (and possibly a TCP or UDP port) to a forwarding target
(load balancer, VPN gateway or VM instance).
Forwarding rules can be either global or regional, specified with the
or
--global flags. For more information
about the scope of a forwarding rule, refer to https://cloud.google.com/load-balancing/docs/forwarding-rule-concepts.
--region=REGION
Forwarding rules can be external, internal, internal managed, or internal
self-managed, specified with the
flag. External forwarding rules are accessible from the internet, while internal
forwarding rules are only accessible from within their VPC networks. You can
specify a reserved static external or internal IP address with the
--load-balancing-scheme=[EXTERNAL|EXTERNAL_MANAGED|INTERNAL|INTERNAL_MANAGED|INTERNAL_SELF_MANAGED] flag for the forwarding
rule. Otherwise, if the flag is unspecified, an ephemeral IP address is
automatically assigned (global IP addresses for global forwarding rules and
regional IP addresses for regional forwarding rules); an internal forwarding
rule is automatically assigned an ephemeral internal IP address from the subnet
specified with the --address=ADDRESS flag. You must
provide an IP address for an internal self-managed forwarding rule.
--subnet
Different types of load balancers work at different layers of the OSI networking model (http://en.wikipedia.org/wiki/Network_layer). Layer 3/4 targets include target pools, target SSL proxies, target TCP proxies, and backend services. Layer 7 targets include target HTTP proxies and target HTTPS proxies. For more information, refer to https://cloud.google.com/load-balancing/docs/forwarding-rule-concepts.
When creating a forwarding rule, exactly one of `_--target-instance_`, `_--target-pool_`, `_--target-http-proxy_`, `_--target-https-proxy_`, `_--target-grpc-proxy_`, `_--target-ssl-proxy_`, `_--target-tcp-proxy_` or `_--target-vpn-gateway_` must be specified.
NAME--backend-service=BACKEND_SERVICE--target-grpc-proxy=TARGET_GRPC_PROXY--target-http-proxy=TARGET_HTTP_PROXY--target-https-proxy=TARGET_HTTPS_PROXY--target-instance=TARGET_INSTANCEcompute/zone property isn't set, you might
be prompted to select a zone (interactive mode only).
To avoid prompting when this flag is omitted, you can set the
property:
compute/zone
gcloud config set compute/zone ZONEA list of zones can be fetched by running:
gcloud compute zones listTo unset the property, run:
gcloud config unset compute/zoneCLOUDSDK_COMPUTE_ZONE.
--target-pool=TARGET_POOL--target-ssl-proxy=TARGET_SSL_PROXY--target-tcp-proxy=TARGET_TCP_PROXY--target-vpn-gateway=TARGET_VPN_GATEWAY--load-balancing-scheme=LOAD_BALANCING_SCHEME; default="EXTERNAL"LOAD_BALANCING_SCHEME must be one
of:
EXTERNALEXTERNAL_MANAGEDINTERNALINTERNAL_MANAGEDINTERNAL_SELF_MANAGED--network=NETWORK--subnet=SUBNET--subnet-region=SUBNET_REGION--target-instance-zone=TARGET_INSTANCE_ZONEcompute/zone property value for this command invocation.
--target-pool-region=TARGET_POOL_REGIONcompute/region property value for this command invocation.
--target-vpn-gateway-region=TARGET_VPN_GATEWAY_REGIONcompute/region property value for this command invocation.
--backend-service-region=BACKEND_SERVICE_REGIONcompute/region property value for this command invocation.
--global-backend-service--global--region=REGION
To avoid prompting when this flag is omitted, you can set the
property:
compute/region
gcloud config set compute/region REGIONA list of regions can be fetched by running:
gcloud compute regions listTo unset the property, run:
gcloud config unset compute/regionCLOUDSDK_COMPUTE_REGION.
At most one of these can be specified:
--global-target-http-proxy--target-http-proxy-region=TARGET_HTTP_PROXY_REGION
To avoid prompting when this flag is omitted, you can set the
property:
compute/region
gcloud config set compute/region REGIONA list of regions can be fetched by running:
gcloud compute regions listTo unset the property, run:
gcloud config unset compute/regionCLOUDSDK_COMPUTE_REGION.
At most one of these can be specified:
--global-target-https-proxy--target-https-proxy-region=TARGET_HTTPS_PROXY_REGION
To avoid prompting when this flag is omitted, you can set the
property:
compute/region
gcloud config set compute/region REGIONA list of regions can be fetched by running:
gcloud compute regions listTo unset the property, run:
gcloud config unset compute/regionCLOUDSDK_COMPUTE_REGION.
At most one of these can be specified:
--global-target-tcp-proxy--target-tcp-proxy-region=TARGET_TCP_PROXY_REGION
To avoid prompting when this flag is omitted, you can set the
property:
compute/region
gcloud config set compute/region REGIONA list of regions can be fetched by running:
gcloud compute regions listTo unset the property, run:
gcloud config unset compute/regionCLOUDSDK_COMPUTE_REGION.
--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 help for details.
gcloud alpha compute forwarding-rules set-targetgcloud beta compute forwarding-rules set-targetgcloud preview compute forwarding-rules set-target
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-05-27 UTC.