By default, Compute Engine instances are created with IPv4 addresses. You can optionally create compute instances that use IPv6 addresses. Compute instances that have both IPv4 and IPv6 configurations are called dual-stack instances. The IPv6 address is in addition to any IPv4 addresses that are configured on the network interface.
You can configure IPv6 addresses on a Compute Engine instance if the subnet that the instance is connected to has an IPv6 range configured.
Any network interface on the compute instance can have IPv6 addresses configured. For more information about configuring multiple network interfaces, see Multiple network interfaces.
The stack type of an instance's network interface determines the type of subnets 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 (Preview).
Additionally, a subnet's IPv6 access type configuration determines whether the subnet has an internal or external IPv6 range. Connected instances inherit the IPv6 access type from the subnet.
For more information about IPv6 addresses, see IPv6 overview.
Limitations
- IPv6-only instances (Preview) are supported with only Ubuntu and Debian OS.
Before you begin
- You must create the network and subnets prior to creating the compute instance.
-
If you haven't already, then set up authentication.
Authentication is
the process by which your identity is verified 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, then initialize it by running the following command:
gcloud init
- 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, then initialize it by running the following command:
gcloud init
For more information, see Authenticate 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 the
Compute Instance Admin (v1) (roles/compute.instanceAdmin.v1
) IAM role on the project.
For more information about granting roles, see Manage access to projects, folders, and organizations.
You might also be able to get the required permissions through custom roles or other predefined roles.
Create a dual-stack instance
To create an instance with an internal IPv4 address and an external IPv6 address, connect the compute instance to a dual-stack subnet.
If you're using Shared VPC, and want to create a dual-stack instance that is connected to a shared subnet, see Create an instance in the Shared VPC documentation.
Console
Go to the Create an instance page.
If prompted, select your project and click Continue. The Create an instance page appears and displays the Machine configuration pane.
In the Machine configuration pane, do the following:
- In the Name field, specify a name for your instance. For more information, see Naming resources.
- Optional: In the Zone field, select a zone for this instance. Choose a zone in a region that contains a subnet that has an IPv6 range configured.
Select the machine family for your instance. The Google Cloud console then displays the machine series that are available for your selected machine family. The following machine family options are available:
- General purpose
- Compute optimized
- Memory optimized
- Storage optimized
- GPUs
In the Series column, select the machine series for your instance.
In the Machine type section, select the machine type for your instance.
In the navigation menu, click Networking. In the Networking pane that appears, do the following:
In the Network interfaces section, click the network interface to expand and edit it.
For Network and Subnetwork, select the network and subnetwork that has an IPv6 range configured.
For IP stack type, select IPv4 and IPv6 (dual-stack).
For Primary internal IPv4 address, select one of the following:
- To assign a new ephemeral IPv4 internal address, choose Ephemeral.
- To assign an existing static external IP address, choose the name of a reserved IPv4 address from the list.
- To create and assign a new static internal IPv4 address, choose Reserve static internal IPv4 address.
Optional: For External IPv4 address, select one of the following:
- To assign an ephemeral external IPv4 address, choose Ephemeral.
- To create an instance without an external IPv4 address, choose None.
- To assign an existing static external IP address, choose the name of a reserved IPv4 address from the list.
- To create and assign a new static external IPv4 address, choose Reserve static external IPv4 address.
Optional: To configure an external IPv6 address, for External IPv6 address, select one of the following:
- To assign a new ephemeral external IPv6 address, choose Auto-allocate.
- To assign an existing static external IP address, choose the name of a reserved IPv6 address from the list.
- To create and assign a new static external IPv6 address, choose Reserve static external IPv6 address.
To finish modifying the network interface, click Done.
Optional: To configure an additional network interface, click Add a network interface and repeat the previous steps for the Networking pane.
Optional: Specify other configuration options. For more information, see Configuration options during instance creation.
To create and start the instance, click Create.
gcloud
Create an instance by using the
gcloud compute instances create
command.
gcloud compute instances create INSTANCE_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; the subnet must have an IPv6 subnet rangeZONE
: the zone to deploy the instance in
REST
- Select an image. Make a note of the name of the image or image family and the name of the project containing the image.
Use the
instances.insert
method to create an instance from an image family or from a specific version of an OS image: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 or custom, for the new instance—for example,n4-standard-2
INSTANCE_NAME
: a name for the new instanceREGION
: the region that contains the subnetSUBNET
: a dual-stack subnetIMAGE_PROJECT
: Optional: the image project that contains the imageIMAGE
: Optional: specify one of the following:- A specific version of the OS image—for example,
debian-12-bookworm-v20241009
- An image 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, see Image 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:
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, the instance can have either an internal or external IPv6 address, depending on the access type of the network to which its interface is connected. You must create a custom mode Virtual Private Cloud (VPC) network with a subnet that has an IPv6 address range.
Before you can create a multi-NIC VM instance that uses both internal and external IPv6 addresses, you must create the following:
- The internal network and subnet: A custom mode VPC network
with IPv6 ULA enabled, a subnet with an IPv6 address range, and the access
type set to
internal
. - The external network and subbet: A second custom mode VPC
network, a second subnet with an IPv6 address range, and the access type set
to
external
.
When you create the instance, you configure two network interfaces, one that connects to the subnet with the internal IPv6 address range and one that connects to the subnet with the external address range.
If you're using Shared VPC, and want to create an IPv6-only instance that is connected to a shared subnet, see Create an instance in the Shared VPC documentation.
Console
Go to the Create an instance page.
If prompted, select your project and click Continue. The Create an instance page appears and displays the Machine configuration pane.
In the Machine configuration pane, do the following:
- In the Name field, specify a name for your instance. For more information, see Naming resources.
- Optional: In the Zone field, select a zone for this instance. Choose a zone in a region that contains a subnet that has an IPv6 range configured.
Select the machine family for your instance. The Google Cloud console then displays the machine series that are available for your selected machine family. The following machine family options are available:
- General purpose
- Compute optimized
- Memory optimized
- Storage optimized
- GPUs
In the Series column, select the machine series for your instance.
In the Machine type section, select the machine type for your instance.
In the navigation menu, click Networking. In the Networking pane that appears, do the following:
In the Network interfaces section, click the network interface to expand and edit it.
For Network and Subnetwork, select the network and subnetwork that has an IPv6 range configured.
The IPv6 access type of the subnet determines whether the instance receives an internal IPv6 address or an external IPv6 address. To assign an internal IPv6 address, you must select a network that was created with the Configure a ULA internal IPv6 range for this VPC Network option. Otherwise, you can configure only external IPv6 addresses.
For IP stack type, select IPv6 (single stack).
If you selected a subnet with an access type of
Internal
, then for Primary internal IPv6 address, select one of the following:- To assign a new ephemeral IPv6 address, choose Auto-allocated (/96)
- To assign an existing static internal IP address, choose the name of a reserved IPv6 address from the list.
- To create and assign a new static internal IPv6 address, choose Reserve static internal IPv6 address.
If you selected a subnet with an access type of
External
, then for External IPv6 address, select one of the following:- To assign a new ephemeral external IPv6 address, choose Auto-allocate.
- To assign an existing static external IP address, choose the name of a reserved IPv6 address from the list.
- To create and assign a new static external IPv6 address, choose Reserve static external IPv6 address.
To finish modifying the network interface, click Done.
Optional: To add an additional IPv6 address, do the following:
- Select Add a network interface.
- Repeat the previous steps in this task for the Networking pane.
Optional: Specify other configuration options. For more information, see Configuration options during instance creation.
To create and start the instance, click Create.
gcloud
Create an instance by using the
gcloud beta compute instances create
command.
To assign both internal and external IPv6 addresses, you must create the
instance with at least two network interfaces.
gcloud beta compute instances create INSTANCE_NAME \ --zone ZONE \ --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 the zone.MACHINE_TYPE
: Optional: machine type, predefined or custom, for the new instance. For example,n4-standard-2
.IMAGE_PROJECT
: Optional: the image project that contains the imageIMAGE
: Optional: specify one of the following:- A specific version of the OS image—for example,
debian-12-bookworm-v202410095
. - An image 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, see Image families best practices.
- A specific version of the OS image—for example,
SIZE
: Optional: the size of the new disk. The value must be a whole number. The default unit of measurement is GiB.SUBNET_INTERNAL_NAME
: name of the subnet that is configured for internal IP addresses to use with the instance.SUBNET_EXTERNAL_NAME
: name of the subnet that is configured for external IP addresses to use with the instance.
REST
- Select an image. Make a note of the name of the image or image family and the name of the project containing the image.
Use the
instances.insert
method to create an instance from an image family or from a specific version of an OS image: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 or custom, 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 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: the image project that contains the imageIMAGE
: Optional: specify one of the following:- A specific version of the OS image—for example,
debian-12-bookworm-v20241009
- An image 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, see Image families best practices.
- A specific version of the OS image—for example,
HTTP method and URL:
POST https://compute.googleapis.com/compute/beta/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:
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/beta/projects/`PROJECT_ID`/zones/`ZONE`", "operationType": "insert", "targetLink": "https://www.googleapis.com/compute/beta/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/beta/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