gcloud alpha compute networks subnets update Stay organized with collections Save and categorize content based on your preferences.
- NAME
- gcloud alpha compute networks subnets update - updates properties of an existing Compute Engine subnetwork
- SYNOPSIS
gcloud alpha compute networks subnets updateNAME[--add-secondary-ranges-with-reserved-internal-range=RANGE_NAME=INTERNAL_RANGE_URL,[…]][--aggregation-interval=AGGREGATION_INTERVAL][--drain-timeout=DRAIN_TIMEOUT; default="0s"][--external-ipv6-prefix=EXTERNAL_IPV6_PREFIX][--flow-sampling=FLOW_SAMPLING][--internal-ipv6-prefix=INTERNAL_IPV6_PREFIX][--ip-collection=IP_COLLECTION][--ipv6-access-type=IPV6_ACCESS_TYPE][--logging-aggregation-interval=LOGGING_AGGREGATION_INTERVAL][--logging-filter-expr=LOGGING_FILTER_EXPR][--logging-flow-sampling=LOGGING_FLOW_SAMPLING][--logging-metadata=LOGGING_METADATA][--logging-metadata-fields=[METADATA_FIELD,…]][--metadata=METADATA][--region=REGION][--stack-type=STACK_TYPE][--add-secondary-ranges=PROPERTY=VALUE,[…] |--[no-]allow-cidr-routes-overlap|--[no-]enable-flow-logs|--[no-]enable-private-ip-google-access|--private-ipv6-google-access-type=PRIVATE_IPV6_GOOGLE_ACCESS_TYPE|--purpose=PURPOSE|--remove-secondary-ranges=RANGE_NAME,[RANGE_NAME,…] |--role=ROLE][GCLOUD_WIDE_FLAG …]
- DESCRIPTION
(ALPHA)gcloud alpha compute networks subnets updateis used to update properties of an existing Compute Engine subnetwork.- EXAMPLES
- To enable external IPv6 addresses on the subnetwork example-subnet-1 innetwork-1, run
gcloudalphacomputenetworkssubnetsupdateexample-subnet-1--stack-type=IPV4_IPV6--ipv6-access-type=EXTERNAL--region=REGION - POSITIONAL ARGUMENTS
NAME- Name of the subnetwork to update.
- FLAGS
--add-secondary-ranges-with-reserved-internal-range=RANGE_NAME=INTERNAL_RANGE_URL,[…]- Adds secondary IP ranges that are associated with internal range resources.
For example,
--add-secondary-ranges-with-reserved-internal-rangerange1=//networkconnectivity.googleapis.com/projects/PROJECT/locations/global/internalRanges/RANGEadds a secondary range with the reserved internal range resource.RANGE_NAME- Name of the secondary range.INTERNAL_RANGE_URL-URL of an internal rangeresource.
--aggregation-interval=AGGREGATION_INTERVAL- Can only be specified if VPC Flow Logs for this subnetwork is enabled. Togglesthe aggregation interval for collecting flow logs. Increasing the interval timewill reduce the amount of generated flow logs for long lasting connections.Default is an interval of 5 seconds per connection.
AGGREGATION_INTERVALmust be one of:interval-10-min,interval-15-min,interval-1-min,interval-30-sec,interval-5-min,interval-5-sec. --drain-timeout=DRAIN_TIMEOUT; default="0s"- The time period for draining traffic from Internal HTTP(S) Load Balancer proxiesthat are assigned addresses in the current ACTIVE subnetwork. For example,
,1hand60meach specify a duration of 1 hour fordraining the traffic. Longer times reduce the number of proxies that aredraining traffic at any one time, and so improve the availability of proxies forload balancing. The drain timeout is only applicable when the [--role=ACTIVE]flag is being used.3600s --external-ipv6-prefix=EXTERNAL_IPV6_PREFIX- The /64 external IPv6 CIDR range to assign to this subnet. The range must beassociated with an IPv6 BYOIP sub-prefix that is defined by the --ip-collectionflag. If you specify --ip-collection but not --external-ipv6-prefix, a random/64 range is allocated from the sub-prefix.
For example,
--external-ipv6-prefix=2600:1901:0:0:0:0:0:0/64 --flow-sampling=FLOW_SAMPLING- Can only be specified if VPC Flow Logs for this subnetwork is enabled. The valueof the field must be in [0, 1]. Set the sampling rate of VPC Flow Logs withinthe subnetwork where 1.0 means all collected logs are reported and 0.0 means nologs are reported. Default is 0.5 which means half of all collected logs arereported.
--internal-ipv6-prefix=INTERNAL_IPV6_PREFIX- The /64 internal IPv6 CIDR range to assign to this subnet. The range must beassociated with an IPv6 BYOIP sub-prefix that is defined by the --ip-collectionflag. If you specify --ip-collection but not --internal-ipv6-prefix, a random/64 range is allocated from the sub-prefix.
For example,
--internal-ipv6-prefix 2600:1901:0:0:0:0:0:0/64 --ip-collection=IP_COLLECTION- Resource reference to a public delegated prefix. The PublicDelegatedPrefix mustbe a sub-prefix in EXTERNAL_IPV6_SUBNETWORK_CREATION orINTERNAL_IPV6_SUBNETWORK_CREATION mode.
--ipv6-access-type=IPV6_ACCESS_TYPE- IPv6 access type can be specified only when the subnet is created, or when thesubnet is first updated to have a stack type of IPV4_IPV6. Once set, the accesstype is immutable.
IPV6_ACCESS_TYPEmust be one of:EXTERNAL- VMs in this subnet can have external IPv6.
INTERNAL- VMs in this subnet can have internal IPv6.
--logging-aggregation-interval=LOGGING_AGGREGATION_INTERVAL- Can only be specified if VPC Flow Logs for this subnetwork is enabled. Togglesthe aggregation interval for collecting flow logs. Increasing the interval timewill reduce the amount of generated flow logs for long lasting connections.Default is an interval of 5 seconds per connection.
LOGGING_AGGREGATION_INTERVALmust be one of:interval-10-min,interval-15-min,interval-1-min,interval-30-sec,interval-5-min,interval-5-sec. --logging-filter-expr=LOGGING_FILTER_EXPR- Can only be specified if VPC Flow Logs for this subnetwork is enabled. Exportfilter used to define which logs should be generated.
--logging-flow-sampling=LOGGING_FLOW_SAMPLING- Can only be specified if VPC Flow logs for this subnetwork is enabled. The valueof the field must be in [0, 1]. Set the sampling rate of VPC flow logs withinthe subnetwork where 1.0 means all collected logs are reported and 0.0 means nologs are reported. Default is 0.5 which means half of all collected logs arereported.
--logging-metadata=LOGGING_METADATA- Can only be specified if VPC Flow Logs for this subnetwork is enabled.Configures whether metadata fields should be added to the reported logs. Defaultis to exclude all metadata.
LOGGING_METADATAmust be oneof:custom,exclude-all,include-all. --logging-metadata-fields=[METADATA_FIELD,…]- Can only be specified if VPC Flow Logs for this subnetwork is enabled and"metadata" is set to CUSTOM_METADATA. The comma-separated list of metadatafields that should be added to reported logs.
--metadata=METADATA- Can only be specified if VPC Flow Logs for this subnetwork is enabled.Configures whether metadata fields should be added to the reported logs. Defaultis to exclude all metadata.
METADATAmust be one of:exclude-all-metadata,include-all-metadata. --region=REGION- Region of the subnetwork to update. If not specified, you might be prompted toselect 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 --stack-type=STACK_TYPE- The stack type for this subnet. Determines if IPv6 is enabled on the subnet.
STACK_TYPEmust be one of:IPV4_IPV6- New VMs in this subnet can have both IPv4 and IPv6 addresses
IPV4_ONLY- New VMs in this subnet will only be assigned IPv4 addresses
- At most one of these can be specified:
--add-secondary-ranges=PROPERTY=VALUE,[…]- Adds secondary IP ranges to the subnetwork for use in IP aliasing.
For example,
--add-secondary-ranges range1=192.168.64.0/24adds asecondary range 192.168.64.0/24 with name range1.RANGE_NAME- Name of the secondary range.RANGE-IP range in CIDR format.
--[no-]allow-cidr-routes-overlap- Allow/disallow this subnetwork's IP address ranges to conflict with existingcustom routes. Use
--allow-cidr-routes-overlapto enable and--no-allow-cidr-routes-overlapto disable. --[no-]enable-flow-logs- Enable/disable VPC Flow Logs for this subnet. If the subnet does not support VPCFlow Logs, this flag has no effect. For more information, seehttps://cloud.google.com/vpc/docs/using-flow-logs.Use
--enable-flow-logsto enable and--no-enable-flow-logsto disable. --[no-]enable-private-ip-google-access- Enable/disable access to Google Cloud APIs from this subnet for instanceswithout a public ip address. Use
--enable-private-ip-google-accessto enable and--no-enable-private-ip-google-accessto disable. --private-ipv6-google-access-type=PRIVATE_IPV6_GOOGLE_ACCESS_TYPE- The private IPv6 google access type for the VMs in this subnet.
PRIVATE_IPV6_GOOGLE_ACCESS_TYPEmust be one of:disable,enable-bidirectional-access,enable-outbound-vm-access. --purpose=PURPOSE- The purpose of the subnetwork can be changed in a few scenarios.
PURPOSEmust be one of:PRIVATE- The default subnet type. Only PEER_MIGRATION subnets can be changed to PRIVATE.
REGIONAL_MANAGED_PROXY- The proxy-only subnet for regional HTTP(S) load balancers. OnlyINTERNAL_HTTPS_LOAD_BALANCER subnets can be changed to REGIONAL_MANAGED_PROXY.
--remove-secondary-ranges=RANGE_NAME,[RANGE_NAME,…]- Removes secondary ranges from the subnetwork.
For example,
--remove-secondary-ranges range2,range3removes thesecondary ranges with names range2 and range3. --role=ROLE- The role is set to ACTIVE to update a BACKUP reserved address range to be thenew ACTIVE address range. Note that the only supported value for this flag isACTIVE since setting an address range to BACKUP is not supported.
This field is only valid when updating a reserved IP address range used for thepurpose of Internal HTTP(S) Load Balancer.
ROLEmust be (only one value is supported):ACTIVE- The ACTIVE subnet that is currently used.
- 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:
gcloudcomputenetworkssubnetsupdategcloudbetacomputenetworkssubnetsupdate
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 2026-02-03 UTC.