What's the command for promoting an externally accessible IPv6 range to static within the VPC subnet?
My VM is accessible at 64bit wide IPv6 range, within a 96bit IPv6 subnet. But I'm afraid these may change without warning... this command seems like it should work:
gcloud compute addresses create myvm-6 --addresses "2600:abcd:abcd:abcd:0:0:0:0" --region us-west2 --subnet neo-ipv6
ERROR: (gcloud.compute.addresses.create) Could not fetch resource:
- Invalid value for field 'resource.address': '2600:abcd:abcd:abcd:0:0:0:0'. Requested IP is not within the range of subnetwork 'neo-ipv6'.
You can only reserve two types of external IP Addresses. Global & Regional, IPv4 supports both but IPv6 only supports Global.
You cannot reserve IPv6 addresses for VM Instances since it only supports Global IP and can only be used for global load balancers as stated on the documentation.
To know more about Regional and global IP addresses check this link.
You can configure external IPv6 addresses on virtual machine instances (VMs) if the subnet that they are connected to has external IPv6 addresses enabled. Enabling external IPv6 addresses on a subnet is supported in some regions.
Create a VM and enable IPv6
You can create a VM with an external IPv6 address only if the subnet that you are connecting it to has external IPv6 addresses enabled.
Replace the following:
INSTANCE_NAME: the name for the instance.
SUBNET_NAME: the subnet to connect the instance to. The subnet must have IPv6 enabled.
ZONE: the zone to deploy the instance in.
Promote an ephemeral external IP address
If your instance has an ephemeral external IP address and you want to permanently assign the IP to your project, promote the ephemeral external IP address to a static external IP address. Promoting an ephemeral external IP address to reserved does not cause Google Cloud to drop packets sent to the instance. This includes packets sent to the instance directly or by means of a load balancer.
To promote an ephemeral external IP address to a static external IP address, provide the ephemeral external IP address using the
--addresses
flag with thecompute addresses create
command. Use theregion
flag to promote an ephemeral regional IP address or theglobal
flag to promote an ephemeral global IP address.Replace the following:
ADDRESS_NAME: the name you want to call this address
IP_ADDRESS: the IP address you want to promote
REGION: the region the regional IP address belongs to
Version of the IP address to be allocated and reserved. The default is IPV4.
IP version can only be specified for global addresses that are generated automatically (i.e., along with the
--global
flag, given--addresses
is not specified) and if the--network-tier
isPREMIUM
.IP_VERSION must be one of: IPV4, IPV6.
Check the references for more information:
Reserving a static external IP address
Configuring IPv6 for instances and instance templates
gcloud compute addresses create
Update: Global IP addresses cannot be assigned to instances... They can only be assigned to a short list of "Global Load Balancers". As of Dec 2021, the current API's do not feature any support for regionally static IPv6 addresses.
Your best bet is to assign a static IPv4 address and rely on 6to4 tunnels. Alternatively, you could use a DynDNS service or the Cloud DNS permission to manually update the address as needed.
Calculator: https://www.vultr.com/resources/ipv4-converter/
The current API's do not allow promotion of IPv6 addresses. So you'll need to enable the IPv6 stack for the instance, create a new regional IPv6 static IP and assign it to the instance by deleting the whole accessConfig and creating new one IPv6 one on nic0. IPv6 is only supported on nic0, so you'll likely need another nic for static IPv4 addresses.