Create an instance that uses IPv6 addresses

By default, Compute Engine instances are created with IPv4 addresses. You canoptionally create compute instances that use IPv6 addresses. Compute instancesthat have both IPv4 and IPv6 configurations are calleddual-stack instances. The IPv6 address is in addition to any IPv4 addressesthat are configured on the network interface.

You can configure IPv6 addresses on a Compute Engine instance ifthe subnet that the instance is connected to has anIPv6 range configured.

Any network interface on the compute instance can have IPv6 addressesconfigured. For more information about configuring multiple network interfaces,seeMultiple network interfaces.

The stack type of an instance's network interface determines the type ofsubnets to which it can connect:

  • IPv4-only network interfaces can connect to dual-stack and IPv4-only subnets.
  • Dual-stack network interfaces can connect to dual-stack subnets.
  • IPv6-only network interfaces can connect to dual-stack and IPv6-only subnets.

Additionally, a subnet's IPv6 access type configuration determines whether thesubnet has an internal or external IPv6 range. Connected instances inherit theIPv6 access type from the subnet.

You can create instances with IPv6 addresses automatically assigned byGoogle Cloud or with IPv6 addresses that you specify. You can specify a staticIPv6 address or a custom ephemeral IPv6 address.

For more information about IPv6 addresses, seeIPv6 overview.

Limitations

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

Before you begin

Required roles

To get the permissions that you need to create an instance with IPv6 addresses, ask your administrator to grant you theCompute Instance Admin (v1) (roles/compute.instanceAdmin.v1) IAM role on the project. For more information about granting roles, seeManage access to projects, folders, and organizations.

You might also be able to get the required permissions throughcustom roles or otherpredefined roles.

Permissions required for this task

To perform this task, you must have the followingpermissions:

  • compute.instances.create on the project
  • To use a custom image to create the VM:compute.images.useReadOnly on the image
  • To use a snapshot to create the VM:compute.snapshots.useReadOnly on the snapshot
  • To use an instance template to create the VM:compute.instanceTemplates.useReadOnly on the instance template
  • To assign alegacy network to the VM:compute.networks.use on the project
  • To specify a static IP address for the VM:compute.addresses.use on the project
  • To assign an external IP address to the VM when using a legacy network:compute.networks.useExternalIp on the project
  • To specify a subnet for the VM:compute.subnetworks.use on the project or on the chosen subnet
  • To assign an external IP address to the VM when using a VPC network:compute.subnetworks.useExternalIp on the project or on the chosen subnet
  • To set VM instance metadata for the VM:compute.instances.setMetadata on the project
  • To set tags for the VM:compute.instances.setTags on the VM
  • To set labels for the VM:compute.instances.setLabels on the VM
  • To set a service account for the VM to use:compute.instances.setServiceAccount on the VM
  • To create a new disk for the VM:compute.disks.create on the project
  • To attach an existing disk in read-only or read-write mode:compute.disks.use on the disk
  • To attach an existing disk in read-only mode:compute.disks.useReadOnly on the disk

Create a dual-stack instance

To create an instance with an internal IPv4 address and an external IPv6address, connect the compute instance to adual-stack subnet.

If you're using Shared VPC, and want to create a dual-stack instancethat is connected to a shared subnet, seeCreate an instancein the Shared VPC documentation.

Console

  1. Go to theCreate an instance page.

    Go to Create an instance

  2. If prompted, select your project and clickContinue. TheCreate an instancepage appears and displays theMachine configuration pane.

  3. In theMachine configuration pane, do the following:

    1. In theName field, specify a name for your instance. For moreinformation, seeNaming resources.
    2. Optional: In theZone field, select a zone for this instance.Choose a zone in a region that contains a subnet that has anIPv6 range configured.
    3. Select the machine family for your instance. The Google Cloud consolethen displays the machine series that are available for yourselected machine family. The following machine family options areavailable:

      • General purpose
      • Compute optimized
      • Memory optimized
      • Storage optimized
      • GPUs

    4. In theSeries column, select the machine series for yourinstance.

    5. In theMachine type section, select the machine type for yourinstance.

  4. In the navigation menu, clickNetworking. In theNetworking panethat appears, do the following:

    1. In theNetwork interfaces section, click the network interface toexpand and edit it.

    2. ForNetwork andSubnetwork, select the networkand subnetwork that has an IPv6 range configured.

    3. ForIP stack type, selectIPv4 and IPv6 (dual-stack).

    4. ForPrimary internal IPv4 address, select one of the following:

      • To assign a new ephemeral IPv4 internal address, chooseEphemeral.
      • To assign an existing static external IP address, choose thename of a reserved IPv4 address from the list.
      • To create and assign a new static internal IPv4 address,chooseReserve static internal IPv4 address.
    5. Optional: ForExternal IPv4 address, select one of thefollowing:

      • To assign an ephemeral external IPv4 address, chooseEphemeral.
      • To create an instance without an external IPv4 address, chooseNone.
      • To assign an existing static external IP address, choose thename of a reserved IPv4 address from the list.
      • To create and assign a new static external IPv4 address, chooseReserve static external IPv4 address.
    6. Optional: To configure an external IPv6 address, forExternal IPv6 address, select one of the following:

      • To automatically assign a new ephemeral external IPv6 address,chooseEphemeral (Automatic).
      • To manually specify a new ephemeral external IPv6 address,chooseEphemeral (Custom).
      • To assign an existing static external IP address, choose thename of a reserved IPv6 address from the list.
      • To create and assign a new static external IPv6 address, chooseReserve static external IPv6 address.
    7. To finish modifying the network interface, clickDone.

    8. Optional: To configure an additional network interface, clickAdd a network interface and repeat the previous steps for theNetworking pane.

  5. Optional: Specify other configuration options. For more information, seeConfiguration options during instance creation.

  6. To create and start the instance, clickCreate.

gcloud

Create an instance by using thegcloud compute instances createcommand. To specify customIPv6 addresses, include theinternal-ipv6-address andexternal-ipv6-address flags. If not specified, ephemeral IPv6 addressesare automatically assigned to the instance by Google Cloud.

gcloud compute instances createINSTANCE_NAME \    --subnet=SUBNET_NAME \    --zone=ZONE \    --stack-type=IPV4_IPV6

Replace the following:

  • INSTANCE_NAME: the name for the instance
  • SUBNET_NAME: the subnet to connect the instance to; thesubnet must have an IPv6 subnet range
  • ZONE: the zone to deploy the instance in

REST

  1. Select animage.Make a note of the name of the imageor image family and the name of the project containing the image.
  2. Use theinstances.insert methodto create an instance from an image family or from aspecific version of an OS image. To specify customIPv6 addresses, include thenetworkInterfaces[].ipv6Address andnetworkInterfaces[].ipv6AccessConfigs[].externalIpv6 fields. If notspecified, ephemeral IPv6 addresses are automatically assigned to theinstance by Google Cloud.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: ID of the project to create the instance in.
    • ZONE: zone to create the instance in.
    • MACHINE_TYPE_ZONE: if using a custom machine type, then specify the zone containing the custom machine type to use for the new instance; otherwise, specify the zone to create the instance in.
    • MACHINE_TYPE: machine type,predefined orcustom, for the new instance—for example,n4-standard-2
    • INSTANCE_NAME: a name for the new instance
    • REGION: the region that contains the subnet
    • SUBNET: a dual-stack subnet
    • IMAGE_PROJECT: Optional: theimage project that contains the image
    • IMAGE: Optional: specify one of the following:

      • A specific version of the OS image—for example,debian-12-bookworm-v20241009
      • Animage family, which must be formatted asfamily/IMAGE_FAMILY. This creates the instance from the most recent, non-deprecated OS image. For example, if you specifyfamily/debian-12, Compute Engine creates an instance using the latest version of the OS image in the Debian 12 image family. For more information about using image families, seeImage families best practices.

    HTTP method and URL:

    POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances

    Request JSON body:

    {    "machineType": "zones/MACHINE_TYPE_ZONE/machineTypes/MACHINE_TYPE",    "name": "INSTANCE_NAME",    "networkInterfaces": [      {        "subnetwork": "regions/REGION/subnetworks/SUBNET",        "stackType": "IPV4_IPV6"      }    ],    "disks": [      {        "initializeParams": {          "sourceImage": "projects/IMAGE_PROJECT/global/images/IMAGE"        },        "boot": true      }    ],}

    To send your request, expand one of these options:

    curl (Linux, macOS, or Cloud Shell)

    Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

    Save the request body in a file namedrequest.json, and execute the following command:

    curl -X POST \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json; charset=utf-8" \
    -d @request.json \
    "https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances"

    PowerShell (Windows)

    Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

    Save the request body in a file namedrequest.json, and execute the following command:

    $cred = gcloud auth print-access-token
    $headers = @{ "Authorization" = "Bearer $cred" }

    Invoke-WebRequest `
    -Method POST `
    -Headers $headers `
    -ContentType: "application/json; charset=utf-8" `
    -InFile request.json `
    -Uri "https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances" | Select-Object -Expand Content

    You should receive a JSON response similar to the following:

    {  "kind": "compute#operation",  "id": "9216044482154695709",  "name": "operation-1739207409646-62dccc7d7bc58-d1350b42-64fdb7f7",  "zone": "https://www.googleapis.com/compute/{api_version}/projects/`PROJECT_ID`/zones/`ZONE`",  "operationType": "insert",  "targetLink": "https://www.googleapis.com/compute/{api_version}/projects/`PROJECT_ID`/zones/`ZONE`/instances/`INSTANCE_NAME`",  "targetId": "2679381553616227357",  "status": "RUNNING",  "user": "USER_ID",  "progress": 0,  "insertTime": "2025-02-10T09:10:10.551-08:00",  "startTime": "2025-02-10T09:10:10.551-08:00",  "selfLink": "https://www.googleapis.com/compute/{api_version}/projects/`PROJECT_ID`/zones/`ZONE`/operations/operation-1565289606387-58f9f62f5989c-e582f586-6d22f38" "kind": "compute#operation"}

Create an IPv6-only instance

To create an IPv6-only instance, follow the steps in this section.

For a Compute Engine instance with a single network interface, theinstance can have either an internal or external IPv6 address, depending onthe access type of the network to which its interface is connected. Youmust create a custom mode Virtual Private Cloud (VPC) network with a subnet thathas an IPv6 address range.

Before you can create a multi-NIC VM instance that uses both internal andexternal IPv6 addresses, you must create the following:

  • The internal network and subnet: A custom mode VPC networkwith IPv6 ULA enabled, a subnet with an IPv6 address range, and the accesstype set tointernal.
  • The external network and subnet: A second custom mode VPCnetwork, a second subnet with an IPv6 address range, and the access type settoexternal.

When you create the instance, you configure two network interfaces, one thatconnects to the subnet with the internal IPv6 address range and one thatconnects to the subnet with the external address range.

If you're using Shared VPC, and want to create an IPv6-onlyinstance that is connected to a shared subnet, seeCreate an instancein the Shared VPC documentation.

Console

  1. Go to theCreate an instance page.

    Go to Create an instance

  2. If prompted, select your project and clickContinue. TheCreate an instancepage appears and displays theMachine configuration pane.

  3. In theMachine configuration pane, do the following:

    1. In theName field, specify a name for your instance. For moreinformation, seeNaming resources.
    2. Optional: In theZone field, select a zone for this instance. Choosea zone in a region that contains a subnet that has an IPv6 range configured.
    3. Select the machine family for your instance. TheGoogle Cloud console then displays the machine series that areavailable for your selected machine family. The following machinefamily options are available:

      • General purpose
      • Compute optimized
      • Memory optimized
      • Storage optimized
      • GPUs

    4. In theSeries column, select the machine series for yourinstance.

    5. In theMachine type section, select the machine type for yourinstance.

  4. In the navigation menu, clickNetworking. In theNetworkingpane that appears, do the following:

    1. In theNetwork interfaces section, click the network interface toexpand and edit it.

    2. ForNetwork andSubnetwork, select the networkand subnetwork that has an IPv6 range configured.

      The IPv6 access type of the subnet determines whether the instancereceives an internal IPv6 address or an external IPv6 address. Toassign an internal IPv6 address, you must select a network that wascreated with theConfigure a ULA internal IPv6 range for this VPC Network option.Otherwise, you can configure only external IPv6 addresses.

    3. ForIP stack type, selectIPv6 (single stack).

    4. If you selected a subnet with an access type ofInternal, then forPrimary internal IPv6 address, select one of the following:

      • To automatically assign a new ephemeral internal IPv6 address,chooseEphemeral (Automatic).
      • To manually specify a new ephemeral internal IPv6 address, chooseEphemeral (Custom).
      • To assign an existing static internal IP address, choose thename of a reserved IPv6 address from the list.
      • To create and assign a new static internal IPv6 address, chooseReserve static internal IPv6 address.
    5. If you selected a subnet with an access type ofExternal, then forExternal IPv6 address, select one of the following:

      • To automatically assign a new ephemeral external IPv6 address,chooseEphemeral (Automatic).
      • To manually specify a new ephemeral external IPv6 address, chooseEphemeral (Custom).
      • To assign an existing static external IP address, choose thename of a reserved IPv6 address from the list.
      • To create and assign a new static external IPv6 address, chooseReserve static external IPv6 address.
    6. To finish modifying the network interface, clickDone.

    7. Optional: To add an additional IPv6 address, do the following:

      1. SelectAdd a network interface.
      2. Repeat the previous steps in this task for theNetworkingpane.
  5. Optional: Specify other configuration options. For more information, seeConfiguration options during instance creation.

  6. To create and start the instance, clickCreate.

gcloud

Create an instance by using thegcloud compute instances create command.To assign both internal and external IPv6 addresses, you must create theinstance with at least two network interfaces. To specify custom IPv6addresses, include theinternal-ipv6-address andexternal-ipv6-addressflags. If not specified, ephemeral IPv6 addresses are automatically assignedto the instance by Google Cloud.

gcloud compute instances createINSTANCE_NAME \    --zoneZONE \    --machine-type=MACHINE_TYPE \    --create-disk=boot=yes,image='projects/IMAGE_PROJECT/global/images/IMAGE',size=SIZE \    --network-interface=subnet=SUBNET_INTERNAL_NAME,stack-type=IPV6_ONLY \    --network-interface=subnet=SUBNET_EXTERNAL_NAME,stack-type=IPV6_ONLY,ipv6-network-tier=PREMIUM

Replace the following:

  • INSTANCE_NAME: a name for the instance
  • ZONE: the zone where the instance is created,such aseurope-west1-b. The instance's region is inferred from thezone.
  • MACHINE_TYPE: Optional: machine type,predefinedorcustom,for the new instance. For example,n4-standard-2.
  • IMAGE_PROJECT: Optional: theimage projectthat contains the image
  • IMAGE: Optional: specify one of thefollowing:
    • A specific version of the OS image—for example,debian-12-bookworm-v202410095.
    • Animage family,which must be formatted asfamily/IMAGE_FAMILY. This createsthe instance from the most recent, non-deprecated OS image. Forexample, if you specifyfamily/debian-12,Compute Engine creates an instance using the latestversion of the OS image in the Debian 12 image family. For moreinformation about using imagefamilies, seeImage families best practices.
  • SIZE: Optional: the size of the newdisk. The value must be a whole number. The default unit ofmeasurement is GiB.
  • SUBNET_INTERNAL_NAME: name of the subnet that isconfigured for internal IP addresses to use with the instance.
  • SUBNET_EXTERNAL_NAME: name of the subnet that isconfigured for external IP addresses to use with the instance.

REST

  1. Select animage.Make a note of the name of the imageor image family and the name of the project containing the image.
  2. Use theinstances.insert methodto create an instance from an image family or from aspecific version of an OS image. To specify custom IPv6 addresses,include thenetworkInterfaces[].ipv6Address andnetworkInterfaces[].ipv6AccessConfigs[].externalIpv6 fields. If notspecified, ephemeral IPv6 addresses are automatically assigned to theinstance by Google Cloud.

    Before using any of the request data, make the following replacements:

    • PROJECT_ID: ID of the project to create the instance in.
    • ZONE: zone to create the instance in.
    • MACHINE_TYPE_ZONE: if using a custom machine type, then specify the zone containing the custom machine type to use for the new instance; otherwise,specify the zone to create the instance in.
    • MACHINE_TYPE: machine type,predefined orcustom, for the new instance—for example,n4-standard-2.
    • INSTANCE_NAME: a name for the new instance
    • REGION: the region that contains the subnet
    • SUBNET_INTERNAL: an IPv6-only subnet. The network for this subnet must have an access type ofINTERNAL and have IPv6 ULA enabled.
    • SUBNET_EXTERNAL: an IPv6-only subnet. The network for this subnet must have an access type ofINTERNAL.
    • IMAGE_PROJECT: Optional: theimage project that contains the image
    • IMAGE: Optional: specify one of the following:

      • A specific version of the OS image—for example,debian-12-bookworm-v20241009
      • Animage family, which must be formatted asfamily/IMAGE_FAMILY. This creates the instance from the most recent, non-deprecated OS image. For example, if you specifyfamily/debian-12, Compute Engine creates an instance using the latest version of the OS image in the Debian 12 image family. For more information about using image families, seeImage families best practices.

    HTTP method and URL:

    POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances

    Request JSON body:

    {    "machineType": "zones/MACHINE_TYPE_ZONE/machineTypes/MACHINE_TYPE",    "name": "INSTANCE_NAME",    "networkInterfaces": [      {        "subnetwork": "regions/REGION/subnetworks/SUBNET_INTERNAL",        "stackType": "IPV6_ONLY"      },      {        "subnetwork": "regions/REGION/subnetworks/SUBNET_EXTERNAL",        "stackType": "IPV6_ONLY"      }    ],    "disks": [      {        "initializeParams": {          "sourceImage": "projects/IMAGE_PROJECT/global/images/IMAGE"        },        "boot": true      }    ]}

    To send your request, expand one of these options:

    curl (Linux, macOS, or Cloud Shell)

    Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

    Save the request body in a file namedrequest.json, and execute the following command:

    curl -X POST \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json; charset=utf-8" \
    -d @request.json \
    "https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances"

    PowerShell (Windows)

    Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

    Save the request body in a file namedrequest.json, and execute the following command:

    $cred = gcloud auth print-access-token
    $headers = @{ "Authorization" = "Bearer $cred" }

    Invoke-WebRequest `
    -Method POST `
    -Headers $headers `
    -ContentType: "application/json; charset=utf-8" `
    -InFile request.json `
    -Uri "https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances" | Select-Object -Expand Content

    You should receive a JSON response similar to the following:

    {  "kind": "compute#operation",  "id": "9216044482154695709",  "name": "operation-1739207409646-62dccc7d7bc58-d1350b42-64fdb7f7",  "zone": "https://www.googleapis.com/compute/v1/projects/`PROJECT_ID`/zones/`ZONE`",  "operationType": "insert",  "targetLink": "https://www.googleapis.com/compute/v1/projects/`PROJECT_ID`/zones/`ZONE`/instances/`INSTANCE_NAME`",  "targetId": "2679381553616227357",  "status": "RUNNING",  "user": "USER_ID",  "progress": 0,  "insertTime": "2025-02-10T09:10:10.551-08:00",  "startTime": "2025-02-10T09:10:10.551-08:00",  "selfLink": "https://www.googleapis.com/compute/v1/projects/`PROJECT_ID`/zones/`ZONE`/operations/operation-1565289606387-58f9f62f5989c-e582f586-6d22f38" "kind": "compute#operation"}

What's next

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.