Configure IPv6 addresses for instances and instance templates

You can configure IPv6 addresses on a Compute Engine instance if thesubnet that the instance is connected to has an IPv6 range configured.

For more information about IPv6, seeIPv6 subnet ranges.

Specifications

  • Compute instances that have both IPv4 and IPv6 configurations aredual-stack.The IPv6 address is in addition to any IPv4 addresses that are configured onthe network interface.

  • Interfaces on dual-stack or IPv6-only instances are allocated a single/96range of IPv6 addresses; the first IPv6 address in the range (/128) isconfigured on the interface.

  • Any interface on the instance can have IPv6 addresses configured. For moreinformation about configuring multiple network interfaces, seeMultiple network interfaces.

  • The stack type of an VM's network interface determines the type of subnetsto which it can connect:

    • IPv4-only interfaces can connect to dual-stack and IPv4-only subnets.
    • Dual-stack interfaces can connect to dual-stack subnets.
    • IPv6-only interfaces can connect to dual-stack and IPv6-only subnets.
  • To configure IPv6 addresses on a network interface, the interface must beconnected to a dual stack or IPv6-onlysubnet.

  • A subnet's IPv6 access type configuration determines whether the subnet has aninternal or external IPv6 range. Connected instances inherit the IPv6 accesstype from the subnet.

  • IPv6-only instances are supported with only Ubuntu and Debian OS images.

Accessing instances using IPv6 addresses

Theimplied IPv6 deny ingress firewall ruleprotects instances by blocking incoming connections to their IPv6 addresses.To access instances using their IPv6 addresses, you must have a higher priorityrule that allows incoming access.

For more information about firewall rules, seeVPC firewall rules andHierarchical firewall policies.

For examples of VPC firewall rules, seeConfigure firewall rules for common use cases.

IPv6 address assignment

The following list describes how IPv6 addresses are assigned to computeinstances.

  • Compute instances are assigned an IPv6 address using DHCPv6. The metadataserver responds to the instance's DHCPv6 requests and sends the firstIPv6 address (/128) from the allocated/96 range in response.

  • The metadata server uses route advertisement to publish the default route tothe instance. The instance can then use this default route for all IPv6traffic.

    You can find the default route for an instance's network interface byconnecting to the instance and querying the metadata server for thegateway-ipv6 entry.

    curl http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/gateway-ipv6 -H "Metadata-Flavor: Google"

    For more information about the metadata server, seeView and query instance metadata.

  • Compute instances are configured with link local IP addresses, which areassigned from thefe80::/10 range, but they are used only forneighbor discovery.

  • The MTU configuration on the instance's network interface applies to bothIPv4 and IPv6 packets, but not all MTU values are supported in allcircumstances. For more information, seeMaximum transmission unit.

Create an instance that uses IPv6 addresses

You can create an instance that uses either a combination of IPv4 and IPv6addresses (dual-stack), or you can create an instance that uses only IPv6addresses.

For information about how to create a Compute Engine instance that usesIPv6 addresses, see the following tasks:

Change the stack type of an instance

You can change the stack type of an existing Compute Engine instance.The stack type can be set to either of the following:

  • IPv4 only (single stack)
  • IPv4 and IPv6 (dual-stack)

If you are changing the stack type to dual-stack, the instance must be connectedto a dual-stack subnet. If you need to change which subnet the instance isconnected to, stop the instance and change the subnet. After the subnet isupdated, you can change the instance's IP stack type.

You can't change the stack type of an IPv6-only instance.

Console

  1. Go to theVM instances page.

    Go to VM instances

  2. Click the name of the instance that you want to assign an IPv6 address to.

  3. From the instance details page, complete the following steps:

    1. ClickEdit.
    2. InNetwork interfaces, expand the interface that you want to edit.
    3. Select theIP stack type:IPv4 only (single-stack) orIPv4 and IPv6 (dual-stack).
    4. ClickDone.
  4. ClickSave.

gcloud

Update the stack type of an instance by using thegcloud compute instances network-interfaces updatecommand

gcloud compute instances network-interfaces updateINSTANCE_NAME \    --stack-type=STACK_TYPE \    --zone=ZONE

Replace the following:

  • INSTANCE_NAME: the name of the instance.
  • STACK_TYPE: the stack type for the instance:IPV4_ONLY orIPV4_IPV6.
  • ZONE: the zone that the instance is deployed in.

REST

Update the stack type of an instance by making aPATCH request to theinstances.updateNetworkInterfacemethod.

PATCH https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME/updateNetworkInterface

Replace the following:

  • PROJECT_ID: the ID of the project that contains the instance.
  • ZONE: the zone that the instance is deployed in.
  • INSTANCE_NAME: the name of the instance.

Example request body:

{    "stackType": "STACK_TYPE",}

ReplaceSTACK_TYPE with the stack type for the instance:IPV4_ONLY orIPV4_IPV6.

Create an instance template with IPv6 addresses

You can create a regional or global instance template that can be used to createdual-stack or IPv6-only instances. For more information, seeCreate instance templates.

You must use the Google Cloud CLI or REST to create an instancetemplate that creates instances that use IPv6 addresses.

gcloud

To create a regional or global instance template, use thegcloud compute instance-templates create command.If you want to create a regional instance template, you must use the--instance-template-region flag to specify the region for the instancetemplate.

The following example creates a global instance template:

gcloud compute instance-templates createTEMPLATE_NAME \    --subnet=SUBNET \    --stack-type=STACK_TYPE

Replace the following:

  • TEMPLATE_NAME: the name for the template.
  • SUBNET: a subnet that has an IPv6 subnet range.
  • STACK_TYPE: the stack type, either IPV4_IPV6 for adual-stack instance, or IPV6_ONLY for an instance with external IPv6address.

REST

To create a regional instance template, use theregionInstanceTemplates.insert method,or, to create a global instance template, use theinstanceTemplates.insert method.

The following example creates a global instance template:

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/instanceTemplates

ReplacePROJECT_ID with the project ID.

Example request body:

{  "name": "INSTANCE_TEMPLATE_NAME"  "properties": {    "machineType": "MACHINE_TYPE",    "networkInterfaces": [      {        "subnetwork": "regions/REGION/subnetworks/SUBNET",        "stackType": "STACK_TYPE",      },    ],    "disks":    [      {        "type": "PERSISTENT",        "boot": true,        "mode": "READ_WRITE",        "initializeParams":        {          "sourceImage": "IMAGE_URI"        }      }    ]  }}

Replace the following:

  • INSTANCE_TEMPLATE_NAME: the name of the instancetemplate.
  • MACHINE_TYPE: the machine type of the instances.For example,c3-standard-4.
  • SUBNET: a subnet that has an IPv6 subnet range.
  • REGION: the region of the subnet.
  • IMAGE_URI: the URI to theimage that you want to use.

    For example, if you specify"sourceImage": "projects/debian-cloud/global/images/family/debian-12",Compute Engine creates an instance from the latest version of theoperating system image in the Debian 12 image family.

To learn more about request parameters, see theinstanceTemplates.insert method.

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-12-15 UTC.