IPv6 Addressing and Subnetting

IPv6 needs a subnet wherever IPv4 does: one per VLAN and one per point-to-point link. A global unicast address has three parts: the global routing prefix the ISP assigns, a subnet field, and the interface ID. With the usual /64 subnets from a /48, the subnet field is the fourth quartet, so listing subnets means counting in that quartet.

In Daveth Pro (Network)14 min video

By , founder of Daveth · Updated

Opening frame of the video walkthrough of IPv6 Addressing and Subnetting

Watch this lesson

14 min · Video walkthrough

In Daveth Pro (Network)

The full 14 min walkthrough is in Daveth Pro (Network). See what the plan opens

What this page answers

How do you find the IPv6 prefix of an address?

Keep the bits of the prefix length and set the rest to 0: 2001:DB8:A50:1234::25 with a /64 is in subnet 2001:DB8:A50:1234::/64. It works the same for global unicast and unique local addresses. Read it in “Listing the subnet IDs”

How does IPv6 subnetting work?

Like IPv4's with a subnet field borrowed in the middle: the company's global routing prefix stays fixed, the subnet ID follows, and the interface ID fills the rest, usually 64 bits. Read it in “Three parts”

Where subnets go

Thursday, month five, week one. Ravi and Maya are on a call again, a blank table shared on screen, with the company's 2001:DB8:A50::/48 at the top: which links get an IPv6 subnet, and which subnet does each get? Nothing is configured yet. This is the plan.

IPv6 uses the same idea of where a subnet is needed as IPv4: one for each VLAN, and one for each point-to-point WAN link, serial or Ethernet. The subnetting itself works much like IPv4's, but with mostly simpler math. Because there are so many addresses, almost everyone uses the easiest prefix length for every subnet: /64. Using /64 everywhere makes IPv6 subnetting as easy as using a /24 mask for every IPv4 subnet, and the ways hosts learn addresses dynamically work better with /64 too.

Sam, listening in from the window desk, adds a line to the sticky note from 04.2: "/64 = 64 prefix bits, not 64 PCs."

Three parts

Remember the IPv4 plan from 04.1. Without subnetting, an IPv4 address has two parts, network and host, and the Class A, B or C rules fix how long the network part is: 8, 16 or 24 bits, with the host part making up the rest of the 32. Subnetting adds a third part, a subnet field in the middle, by shortening the host part ("borrowing host bits"). The network part stays locked by the class; the line between subnet and host moves with the mask. Maya's plan used 10.0.0.0 with a /24: 8 network bits, 16 subnet bits, 8 host bits.

IPv6 uses the same three-part idea:

  • The global routing prefix comes first, the same in every address in the company. IANA, an RIR or the ISP sets it.
  • The subnet field sits in the middle, for numbering the company's subnets, much like the IPv4 subnet field.
  • The interface ID comes last and works like the IPv4 host part.

Call their lengths P, S and I: P + S + I = 128.

Network drawing: Three parts in each. The IPv4 network part is fixed by its class; the IPv6 global routing prefix is fixed by the assignment. Either way, the subnet field is the company's to number. Bars are drawn to scale within each row.

IPv6 has no classes, so no rule presets how long the global routing prefix is. Instead, the assignment comes with its prefix length, and after that the length is basically locked. It's often between /32 and /48, and possibly as long as /56. The interface ID is often 64 bits. It doesn't have to be, but 64 works well in real networks and there's no reason to avoid it. So the subnet field is usually 64 - P bits. For the company, P is 48, so S is 16. A company given a /56 would have 8 subnet bits, and one given a /60 just 4.

That's 2 to the power 16: 65,536 subnets. Few companies need that many. And each subnet has 2 to the power 64 interface IDs: over a billion billion (10 to the power 18) addresses, minus some reserved values. Both numbers are far more than needed, and /64 cuts the 128-bit address neatly in half, which keeps the math simple.

You can think of the /48 as a building the ISP handed the company: the global routing prefix is the street address, the subnet field is the room number, and the interface ID is the seat. (Where it stops: every room here gets the same enormous number of seats, 2 to the power 64, whether it needs 3 or 300.)

Listing the subnet IDs

Each subnet needs a number to identify it, as in IPv4: the subnet ID, informally, or prefix ID, formally. Routers list it in their routing tables along with the prefix length. Finding the subnet ID of one address is 06.2's math, and it works the same for global unicast and unique local addresses: an address like 2001:DB8:A50:1234::25 is in subnet 2001:DB8:A50:1234::/64.

To list all the subnet IDs, with one prefix length for every subnet, follow three rules:

  1. Every subnet ID begins with the global routing prefix.
  2. Each subnet gets a different value in the subnet field.
  3. Every subnet ID has all 0s in the interface ID.

For the company, the first 12 hex digits (2001:0DB8:0A50) never change, the fourth quartet takes every value, and the last four quartets of 0s shorten to ::. The list starts like this:

The subnet field counts in hex, so after F comes 10: the quartet 0010, which is sixteen, not ten. Any combination of hex digits is allowed in that fourth quartet, 0000 to FFFF.

Hex counts past nine with letters. It didn't let the alphabet in for decoration.