gcloud compute routers nats create NAME --router=ROUTER [--async] [--auto-network-tier=AUTO_NETWORK_TIER] [--[no-]enable-dynamic-port-allocation] [--enable-endpoint-independent-mapping] [--enable-logging] [--endpoint-types=[ENDPOINT_TYPE,…]] [--icmp-idle-timeout=ICMP_IDLE_TIMEOUT] [--log-filter=LOG_FILTER] [--max-ports-per-vm=MAX_PORTS_PER_VM] [--min-ports-per-vm=MIN_PORTS_PER_VM] [--region=REGION] [--rules=RULES] [--tcp-established-idle-timeout=TCP_ESTABLISHED_IDLE_TIMEOUT] [--tcp-time-wait-timeout=TCP_TIME_WAIT_TIMEOUT] [--tcp-transitory-idle-timeout=TCP_TRANSITORY_IDLE_TIMEOUT] [--type=TYPE] [--udp-idle-timeout=UDP_IDLE_TIMEOUT] [--auto-allocate-nat-external-ips | --nat-external-ip-pool=IP_ADDRESS,[IP_ADDRESS,…]] [--nat-all-subnet-ip-ranges | --nat-custom-subnet-ip-ranges=SUBNETWORK[:RANGE_NAME|:ALL],[…] | --nat-primary-subnet-ip-ranges] [--nat64-all-v6-subnet-ip-ranges | --nat64-custom-v6-subnet-ip-ranges=SUBNETWORK,[SUBNETWORK,…]] [GCLOUD_WIDE_FLAG …]
gcloud compute routers nats create is used to create a NAT on a
Compute Engine router.
gcloud compute routers nats create nat1 --router=my-router --auto-allocate-nat-external-ips --nat-all-subnet-ip-rangesSpecify IP addresses for NAT: Each IP address is the name of a reserved static IP address resource in the same region.
gcloud compute routers nats create nat1 --router=my-router --nat-external-ip-pool=ip-address1,ip-address2Specify subnet ranges for NAT:
By default, NAT works for all primary and secondary IP ranges for all subnets in the region for the given VPC network. You can restrict which subnet primary and secondary ranges can use NAT.
gcloud compute routers nats create nat1 --router=my-router --auto-allocate-nat-external-ips --nat-custom-subnet-ip-ranges=subnet-1,subnet-3:secondary-range-1NAME--router=ROUTER--async--auto-network-tier=AUTO_NETWORK_TIERAUTO_NETWORK_TIER must be one of:
PREMIUMSTANDARD--[no-]enable-dynamic-port-allocationIf not specified, Dynamic Port Allocation is disabled by default.
Use--enable-dynamic-port-allocation to enable and
--no-enable-dynamic-port-allocation to disable.
--enable-endpoint-independent-mappingIf not specified, NATs have endpoint-independent mapping disabled by default.
Use--no-enable-endpoint-independent-mapping to disable
endpoint-independent mapping.
--enable-logging--endpoint-types=[ENDPOINT_TYPE,…]ENDPOINT_TYPE must be one of:
ENDPOINT_TYPE_VM For VM Endpoints ENDPOINT_TYPE_SWG For Secure Web Gateway Endpoints ENDPOINT_TYPE_MANAGED_PROXY_LB For regional Application Load Balancers (internal and external) and regional proxy Network Load Balancers (internal and external) endpoints
The default is ENDPOINT_TYPE_VM.
ENDPOINT_TYPE must be one of:
ENDPOINT_TYPE_VM, ENDPOINT_TYPE_SWG,
ENDPOINT_TYPE_MANAGED_PROXY_LB.
--icmp-idle-timeout=ICMP_IDLE_TIMEOUT--log-filter=LOG_FILTERThe default is ALL.
If logging is not enabled, filter settings will be persisted but will have no effect.
Use --[no-]enable-logging to enable and disable logging.
LOG_FILTER must be one of:
ALLERRORS_ONLYTRANSLATIONS_ONLY--max-ports-per-vm=MAX_PORTS_PER_VM--min-ports-per-vm=MIN_PORTS_PER_VMIf Dynamic Port Allocation is disabled, this defaults to 64.
If Dynamic Port Allocation is enabled, this defaults to 32 and must be set to a power of 2 that is at least 32 and lower than maxPortsPerVm.--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.
--rules=RULES--tcp-established-idle-timeout=TCP_ESTABLISHED_IDLE_TIMEOUT--tcp-time-wait-timeout=TCP_TIME_WAIT_TIMEOUT--tcp-transitory-idle-timeout=TCP_TRANSITORY_IDLE_TIMEOUT--type=TYPETYPE must be one of:
PRIVATEPUBLIC--udp-idle-timeout=UDP_IDLE_TIMEOUT--auto-allocate-nat-external-ips--nat-external-ip-pool=IP_ADDRESS,[IP_ADDRESS,…]--nat-all-subnet-ip-ranges--nat-custom-subnet-ip-ranges=SUBNETWORK[:RANGE_NAME|:ALL],[…]SUBNETWORK:ALL - specifying a subnetwork name with ALL includes the
primary range and all secondary ranges of the subnet.
SUBNETWORK - including a subnetwork name includes only the primary
subnet range of the subnetwork.
SUBNETWORK:RANGE_NAME - specifying a subnetwork and secondary range
name includes only that secondary range. It does not include the primary range
of the subnet.
--nat-primary-subnet-ip-ranges--nat64-all-v6-subnet-ip-ranges--nat64-custom-v6-subnet-ip-ranges=SUBNETWORK,[SUBNETWORK,…]--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.
The beta command uses the compute/beta/routers API. The full documentation for this API can be found at: https://cloud.google.com/compute/docs/reference/rest/beta/routers/
The alpha command uses the compute/alpha/routers API. Full documentation is not
available for the alpha API.
gcloud alpha compute routers nats creategcloud beta compute routers nats creategcloud preview compute routers nats create
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.