Create an instance that uses IPv6 addresses Stay organized with collections Save and categorize content based on your preferences.
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
- You mustcreate the network and subnetsprior to creating the compute instance.
- If you haven't already, set upauthentication. Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
Install the Google Cloud CLI. After installation,initialize the Google Cloud CLI by running the following command:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.- Set a default region and zone.
REST
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI. After installation,initialize the Google Cloud CLI by running the following command:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.For more information, seeAuthenticate for using REST in the Google Cloud authentication documentation.
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.createon the project- To use a custom image to create the VM:
compute.images.useReadOnlyon the image - To use a snapshot to create the VM:
compute.snapshots.useReadOnlyon the snapshot - To use an instance template to create the VM:
compute.instanceTemplates.useReadOnlyon the instance template - To assign alegacy network to the VM:
compute.networks.useon the project - To specify a static IP address for the VM:
compute.addresses.useon the project - To assign an external IP address to the VM when using a legacy network:
compute.networks.useExternalIpon the project - To specify a subnet for the VM:
compute.subnetworks.useon the project or on the chosen subnet - To assign an external IP address to the VM when using a VPC network:
compute.subnetworks.useExternalIpon the project or on the chosen subnet - To set VM instance metadata for the VM:
compute.instances.setMetadataon the project - To set tags for the VM:
compute.instances.setTagson the VM - To set labels for the VM:
compute.instances.setLabelson the VM - To set a service account for the VM to use:
compute.instances.setServiceAccounton the VM - To create a new disk for the VM:
compute.disks.createon the project - To attach an existing disk in read-only or read-write mode:
compute.disks.useon the disk - To attach an existing disk in read-only mode:
compute.disks.useReadOnlyon 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
Go to theCreate an instance page.
If prompted, select your project and clickContinue. TheCreate an instancepage appears and displays theMachine configuration pane.
In theMachine configuration pane, do the following:
- In theName field, specify a name for your instance. For moreinformation, seeNaming resources.
- 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.
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
In theSeries column, select the machine series for yourinstance.
In theMachine type section, select the machine type for yourinstance.
In the navigation menu, clickNetworking. In theNetworking panethat appears, do the following:
In theNetwork interfaces section, click the network interface toexpand and edit it.
ForNetwork andSubnetwork, select the networkand subnetwork that has an IPv6 range configured.
ForIP stack type, selectIPv4 and IPv6 (dual-stack).
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.
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.
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.
To finish modifying the network interface, clickDone.
Optional: To configure an additional network interface, clickAdd a network interface and repeat the previous steps for theNetworking pane.
Optional: Specify other configuration options. For more information, seeConfiguration options during instance creation.
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 instanceSUBNET_NAME: the subnet to connect the instance to; thesubnet must have an IPv6 subnet rangeZONE: the zone to deploy the instance in
REST
- Select animage.Make a note of the name of the imageor image family and the name of the project containing the image.
Use the
instances.insertmethodto create an instance from an image family or from aspecific version of an OS image. To specify customIPv6 addresses, include thenetworkInterfaces[].ipv6AddressandnetworkInterfaces[].ipv6AccessConfigs[].externalIpv6fields. 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-2INSTANCE_NAME: a name for the new instanceREGION: the region that contains the subnetSUBNET: a dual-stack subnetIMAGE_PROJECT: Optional: theimage project that contains the imageIMAGE: 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 as
family/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.
- A specific version of the OS image—for example,
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 thegcloudCLI with your user account by runninggcloud initorgcloud auth login, or by usingCloud Shell, which automatically logs you into thegcloudCLI . You can check the currently active account by runninggcloud auth list.Save the request body in a file named
request.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 thegcloudCLI with your user account by runninggcloud initorgcloud auth login. You can check the currently active account by runninggcloud auth list.Save the request body in a file named
request.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 ContentYou 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 to
internal. - The external network and subnet: A second custom mode VPCnetwork, a second subnet with an IPv6 address range, and the access type setto
external.
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
Go to theCreate an instance page.
If prompted, select your project and clickContinue. TheCreate an instancepage appears and displays theMachine configuration pane.
In theMachine configuration pane, do the following:
- In theName field, specify a name for your instance. For moreinformation, seeNaming resources.
- 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.
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
In theSeries column, select the machine series for yourinstance.
In theMachine type section, select the machine type for yourinstance.
In the navigation menu, clickNetworking. In theNetworkingpane that appears, do the following:
In theNetwork interfaces section, click the network interface toexpand and edit it.
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.
ForIP stack type, selectIPv6 (single stack).
If you selected a subnet with an access type of
Internal, 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.
If you selected a subnet with an access type of
External, 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.
To finish modifying the network interface, clickDone.
Optional: To add an additional IPv6 address, do the following:
- SelectAdd a network interface.
- Repeat the previous steps in this task for theNetworkingpane.
Optional: Specify other configuration options. For more information, seeConfiguration options during instance creation.
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 instanceZONE: 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 imageIMAGE: Optional: specify one of thefollowing:- A specific version of the OS image—for example,
debian-12-bookworm-v202410095. - Animage family,which must be formatted as
family/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.
- A specific version of the OS image—for example,
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
- Select animage.Make a note of the name of the imageor image family and the name of the project containing the image.
Use the
instances.insertmethodto create an instance from an image family or from aspecific version of an OS image. To specify custom IPv6 addresses,include thenetworkInterfaces[].ipv6AddressandnetworkInterfaces[].ipv6AccessConfigs[].externalIpv6fields. 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 instanceREGION: the region that contains the subnetSUBNET_INTERNAL: an IPv6-only subnet. The network for this subnet must have an access type ofINTERNALand 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 imageIMAGE: 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 as
family/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.
- A specific version of the OS image—for example,
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 thegcloudCLI with your user account by runninggcloud initorgcloud auth login, or by usingCloud Shell, which automatically logs you into thegcloudCLI . You can check the currently active account by runninggcloud auth list.Save the request body in a file named
request.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 thegcloudCLI with your user account by runninggcloud initorgcloud auth login. You can check the currently active account by runninggcloud auth list.Save the request body in a file named
request.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 ContentYou 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
- Configure IPv6 addresses for instances and instance templates
- Create VMs with multiple network interfaces
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.