IPv6 subnet calculator

Split an IPv6 prefix into /64s, with each range and the AWS, Azure and GCP subnet rules.

Input

Compressed or expanded, in upper or lower case. An address with no prefix length is read as its /64.
Examples
A prefix length: /64 is the only size Azure and Google Cloud take
In decimal or as hex (0x1f)

Result

Subnets
—
Expanded form: where the prefix ends

Subnet 0

Cloud subnet rules

Subnets

Guide

How many /64 subnets fit in a /56

An IPv6 address has 128 bits, written as 8 groups of 4 hex digits. A prefix such as 2001:db8:1234:1a00::/56 fixes the first 56 bits. To make /64 subnets, the calculator numbers them with the 8 bits between 56 and 64, so a /56 holds 264 − 56 = 256 subnets. Each hex digit is 4 bits, so those 8 bits are the last two digits of the fourth group: the subnets run from 2001:db8:1234:1a00::/64 to 2001:db8:1234:1aff::/64.

A prefix length that is a multiple of 4 ends on a hex digit (a nibble boundary), so the subnet number fills whole hex digits. A /57 splits a digit in two, and the subnet numbers no longer match the digits you read. AWS accepts VPC and subnet sizes only in steps of 4.

Usable addresses on AWS, Azure and Google Cloud

A /64 holds 264 addresses, so running out is not the problem. What differs is the subnet sizes each provider accepts and the addresses it keeps:

CloudSubnet sizesReserved in each subnet
AWS/44 to /64, steps of 4First 4, last 1
Azure/64First 4, last 1
Google Cloud/64First and last /96 (internal ranges)

On AWS the second address of a subnet is the VPC router. The IPv6 block Amazon assigns to a VPC is a fixed /56, enough for 256 subnets; blocks from IPAM or your own addresses can be /44 to /60. Azure's IPv6 planning guide says IPv6 subnets reserve their first four addresses, and its Virtual Network FAQ says every subnet also loses its last address, so the calculator counts five. On Google Cloud, a VPC network with internal IPv6 gets one /48 from fd20::/20; each subnet's internal range is a /64 of it, and each VM interface gets a /96. In an external /64 that Google Cloud assigns, VM interfaces use the first half and Cloud Load Balancing the second. With your own addresses (BYOIP), a subnet's /64 can be external, for VM interfaces only, or internal, working like an fd20::/20 range.

Subnets smaller than /64 break address autoconfiguration (SLAAC): interface IDs are 64 bits (RFC 4291), and SLAAC ignores a prefix that leaves no room for one (RFC 4862). AWS, Azure and Google Cloud don't accept them either. A link between two routers can use a /127 (RFC 6164). For IPv4 blocks, use the CIDR calculator.

Pitfall: a prefix with host bits

RFC 4291 lists this as a wrong way to write a /60: 2001:0DB8::CD30/60 is not 2001:db8:0:cd30::/60. The :: fills the middle with zeros, so the address ends in cd30 and its /60 is 2001:db8::/60. The calculator shows which network it used.

Terraform's cidrsubnet() drops host bits without a warning. Its own docs example passes fd00:fd12:3456:7890::/56, where the 90 lies outside the /56, and gets the same answer as for fd00:fd12:3456:7800::/56:

cidrsubnet("fd00:fd12:3456:7890::/56", 16, 162)
# "fd00:fd12:3456:7800:a200::/72"

Write the network address, so every tool reads the same block.

Compressed and expanded forms

RFC 5952 defines one text form: lowercase, no leading zeros, and the longest run of two or more zero groups written as :: (the first one on a tie). A single zero group stays 0. Below, two runs of two zero groups tie, so only the first becomes :::

2001:0DB8:0000:0000:0001:0000:0000:0001
2001:db8::1:0:0:1

The expanded form writes all 32 hex digits. Reverse DNS names under ip6.arpa list them in reverse order, one digit per label (RFC 3596).

FAQ

How many /64 subnets are in a /56?

256. The number of subnets is 2 to the power of the difference between the two prefix lengths: 2^(64 - 56) = 256. A /60 holds 16 /64 subnets, a /52 holds 4,096, a /48 holds 65,536 and a /44 holds 1,048,576.

Which IPv6 addresses do AWS, Azure and Google Cloud reserve in a subnet?

AWS reserves the first four addresses and the last one; the second address is the VPC router. Azure's IPv6 guide names the first four addresses, and its Virtual Network FAQ says every subnet also loses its last address. Google Cloud reserves the first and last /96 of a subnet's internal /64. In an external /64 that Google Cloud assigns, VM interfaces use the first half and Cloud Load Balancing the second; an external /64 from your own addresses (BYOIP) is for VM interfaces only. Each VM interface gets a /96.

Why are IPv6 subnets /64?

RFC 4291 requires 64-bit interface IDs for most unicast addresses, and stateless address autoconfiguration (SLAAC) ignores a prefix that leaves no room for one (RFC 4862). Azure and Google Cloud subnets are exactly /64. AWS also accepts larger subnets, from /44 to /60 in steps of 4, as long as the VPC block is at least that big, but nothing smaller than /64.

What IPv6 prefix size does an AWS VPC get?

The IPv6 block Amazon assigns to a VPC is a fixed /56, which holds 256 /64 subnets, and you cannot choose its range. With addresses from Amazon VPC IP Address Manager (IPAM) or your own (BYOIP), a VPC block can be /44 to /60 in steps of 4.

How do I split an IPv6 prefix with Terraform's cidrsubnet()?

Call cidrsubnet(prefix, newbits, netnum), where newbits is the subnet size minus the prefix length and netnum is the subnet number. cidrsubnet("2001:db8:1234:1a00::/56", 8, 3) returns 2001:db8:1234:1a03::/64. For several subnets in a row, cidrsubnets("2001:db8:1234:1a00::/56", 8, 8, 8) returns the first three /64s; unlike cidrsubnet, it adds at most 32 bits per subnet. The calculator writes the call for the subnet you pick.

What is the difference between compressed and expanded IPv6?

They are the same address written two ways. The expanded form has all 32 hex digits in 8 groups of 4: 2001:0db8:0000:0000:0000:0000:0000:0001. The compressed form (RFC 5952) drops leading zeros and replaces the longest run of zero groups with "::": 2001:db8::1.

More tools