0000 0000 0000 0000 0000 0000 0000 0000

0000 0000 0000 0000 0000 0000 0101 0010

0000 0000 0000 0000 0000 0000 0000 0001

The first step in compressing this address is to convert groups of sixteen bits into groups of four hexadecimal (

This is an entirely legal representation, a well-formed address. Another, optional, step is to leave out any leading zeros in any group of four digits. That lets us compress the address a lot:

Another step, again optional, is to collapse one run of consecutive zero groups into a single empty group. We can do this to only one consecutive sequence of zero groups. If we did it to more than one sequence, there would be no way to reconstruct how many zeroes were in each sequence. If we have two sequences, we can collapse either. So now we can write this:

Handy hint: Think of the double colon as meaning

We use this notation whenever we are talking about a whole network, and don't care about the individual addresses in it. The above can also be read as

If we are talking about a specific address, the prefix sometimes doesn't matter, because we have specified every bit in the address. So this is an address – no need to specify a prefix:

However, addresses are often written with their proper prefix included, like this:

The /64 tells us that this is an address with a 64 bit prefix. Writing addresses this way can result in confusion (see also Subnetting Traps below), so always make sure it is clear from the context if you have written an address with a prefix length.

2001:db8:0001::/48

Notice that the difference is that a further 16 bits have been specified (remember each hex digit represents 4 bits). The original 32 plus the additional 16 make 48 in all.

16 bits can express 65536 distinct values, so there are 65536 distinct /48 networks in any /32 network:

2001:db8:0001::/4

[... 65532 subnets omitted ...]

2001:db8:FFFF::/48

The bigger the prefix, the smaller the network, in the sense that it can contain fewer hosts. A /96 is a network the size of the entire existing IPv4 Internet, because it has 32 bits' worth of host addresses in it (96 + 32 = 128). A /120 has only 8 bits left for hosts, so it's the same size as an IPv4 Class C subnet: 256 addresses.

Consider the eight /64 subnets below:

P:0001::/64

P:0002::/64 P:0002::/63

P:0003::/64

P:0004::/64 P:0004::/63 P:0004::/62

P:0005::/64

P:0006::/64 P:0006::/63

P:0007::/64

P represents the first 48 bits. The table columns show that the addresses from

Saying we want a /63 is the same as saying that the first 63 bits of any address in that network form the prefix part, and the remainder form the host part. That means that bit 64 is in the host part, because it is not one of the first 63 bits. But in

In other words,

By the same logic, we can't have

How many /64 networks are there in a /60? Again, deduct the size of the network from the size of the subnet: 64 - 60 = 4, and 2

It works for any size prefix and subnet. How many /93 subnets are there in a /91 network? 93 - 91 = 2, so there are four subnets. How many /12 subnets in a /9 network? 12 - 9 = 3, so there are eight subnets. And so on. How many /112 subnets in a /14 network?

Subnet calculations are easier with hex and IPv6 than with decimal and IPv4. Still, they can be wearisome. There are many good subnet calculators available on the web – just search for "IPv6 subnet calculator". At time of writing, there was a very good crop at http://www.subnetonline.com.

Note: This primer just discusses the basic binary bits. An IPv6 address has more structure than this, and various bit patterns – especially in the first octet – are special. There are also conventions and standards around subnet sizes. For more information, see RFC4291.

Karl Auer, April 2011

IPv6 Prefix Primer ©2008-2015 IPv6 Now Pty Ltd