## IPv6 Subnetting - Bit Based Subnetting

- Details
- Written by Lawrence Hughes

IPv6 Subnetting is fairly simple if you can subdivide your addresses with 16 branches at each of four levels (as covered in the Basic Concepts article):

But what if your requirement doesn't fall neatly into these levels? For example, you have a /48 and need to divide it up into 900 equal sized blocks for a lot of branch offices, each of which want to be able to provision as many subnets as possible with /64 blocks.

You can't use /52 blocks, you have only 16 of them. You can't use /56 blocks, you have only 256 of them. You *could* use /60 blocks, because you have 4096 of them. But with /60 blocks, you can only provision 16 subnets in each. But 75% of your /60 subnets are not being used.

The solution is to do bit-based subnetting - in other words, using a block size that is not on a 4-bit boundary. How do you calculate how many bits to use?

You could try them one by one. The /56 blocks are too big (not enough of them), and the /60 blocks aren't big enough (can only provision 16 subnets with each). So, try the values in between:

There are 512 /57 blocks in a /48, each of which can provision 128 subnets.

There are 1024 /58 blocks in a /48, each of which can provision 64 subnets.

There are 2048 /59 blocks in a /48, each of which can provision 32 subnets.

Ah! We have an answer - break your /48 up into 1024 /58 blocks. That will handle your 900 branch offices, and allow each of them to have 64 subnets (better than only 16 subnets each). The only problem is the prefixes are a little tricky since /58 doesn't fall on hex digit boundaries. So what do your prefixes look like?

If your /48 was 2001:470:3d::/48, the prefixes of the 1024 /58 blocks would be:

You could calculate how many bits you need, but since there are only 16 possible places to divide the Subnet ID, the easiest solution is to use the following chart:

A quick glance at this would tell you that /58 is the shortest prefix length that will give you enough equal sized blocks to provision 900 branch offices, and each is able to provision 64 subnets.

You should of course take growth into account. The /58 prefix length could only accomodate 1024 branch offices. Is your organization likely to add more than 124 additional branch offices in the next decade? If not, great - use /58. If so, it would be safer to choose /59 block size (assuming being able to provision only 32 subnets per branch is sufficient). This would allow growth to more than double the current 900 branch offices (actually up to 2048 branch offices).

What if you have a few big branch offices that need to provision more than 32 subnets each? You could simply allocate multiple contiguous /59 blocks to those offices (on power of two boundaries, so that a single CIDR prefix could specify it). For example, your biggest branch office might require four /59 blocks (they need to provision up to 128 subnets). Give them the first four contiguous /59 blocks (that is actually a /57 block). The next three branch offices might require two /59 blocks each (they need to provision up to 64 subnets each). Given each of them two contiguous /59 blocks (those are actually /58 blocks). All the rest can make do with a single /59 block. The routing can be set up easily to provide each branch office what they need. For example:

To provide for growth, you could provide the big branch offices with even larger contiguous chunks (e.g. give your biggest branch not just 4 contiguous /59 blocks, but 8 - a /56 block), until you get down to those for which a /59 block will be enough for the next decade. Just be careful to line up allocated blocks on power of two boundaries. If you allocate contiguous blocks in power of two groups (2, 4, 8, 16), and start with the first /59 block, this will naturally happen.

The IPv6 subnet calculators available online may help you with these decisions. For example, see the calculator at subnetonline.com. If you enter the "Address" (actually *prefix*) as 2001:470:3d:/48, and choose 900 subnets (enter 900 and click Add Level), it will tell you that you need 10 bits (hence /58 blocks). On the result page (if you expand the 2001:470:3d::/48 item), it will show the following list:

and so on. Looks a lot like what we came up with by hand. You would have to know that 2^{10} is 1,024, which doesn't leave a lot of room to expand. In my opinion, it's easier to do it by hand, using the above table.