ITNuvoAkademiya
Academy homePackagesPlaylistsToolsSubnet calculatorSearchGlossary
CiscoCCNA · CCNA: networking fundamentals1. Introduction2. Network Fundamentals3. Network Access4. IP Connectivity5. IP Services6. IPv67. Security Fundamentals8. AutomationCCNP: Enterprise networks · coming soon
LinuxLinux: system administrator üçün · Linux for system administrators1. Getting to know Linux2. Working with text3. Users and permissions4. Processes and packages5. Inside the system6. Monitoring and logs7. NetworkingRed Hat Enterprise Linux · Red Hat Enterprise Linux: from beginner to advanced1. Getting started2. Packages3. Users and permissions4. SELinux5. Services6. Storage7. Networking8. Building services9. Boot and recovery10. DevOps11. Security and monitoring
FortinetFortiGate Administrator · FortiGate Administrator: from first login to ZTNA1. Getting to know FortiGate2. Routing, policy and NAT3. Security profiles4. Users and logs5. Resilience, SD-WAN and automation6. VDOM7. VPN and ZTNA8. Proxy9. DMZ
MonitoringZabbix · Zabbix: from installation to alerts1. Introduction2. Installation and the database3. Basics: groups, templates, users4. Connecting devices5. Alerts, Grafana and the API
VirtualizationProxmox VE · coming soonVMware ESXi · coming soon
My account / Sign in
AZENRU
← itnuvo.com

IPv6 prefix and prefix length: calculating the prefix step by step

Lesson 6.28 minIntermediateNovember 16, 2026
Open

This lesson is open to everyone. The other lessons open with a package: sign in or sign up, then choose a package.

Key points

  • IPv6 has no subnet mask, it has a prefix length: 2001:DB8:AC10:FE01::/64. The number after / is the number of prefix bits.
  • 1 hex character = 4 bits, 1 group = 16 bits. /64 = the first 16 hex characters (four groups) are the prefix, the last 64 bits the interface ID.
  • Writing the prefix: set the host bits to zero, complete the address to 128 bits and shorten it: 2001:DB8:AC10:FE01:0:0:0:0/64 → 2001:DB8:AC10:FE01::/64.
  • With a shortened address, first expand ::: 2001:DB8::7:AB12:34CD:56EF:7890 → 2001:0DB8:0000:0007:... → prefix 2001:DB8:0:7::/64.
  • If the prefix length is not a multiple of 16 or 4, convert the boundary group to binary: ...:9ABC:.../53 → keep the first 5 bits → 2001:DB8:CAFE:9800::/53.

A prefix length instead of a subnet mask

IPv4 addresses have a subnet mask. In IPv6, instead of typing something like 255.255.255.0, we use a prefix length. An example of an IPv6 prefix:

2001:DB8:AC10:FE01::/64

This is very similar to writing 192.168.10.0 /24 in IPv4. The number after / is the number of bits used for the prefix. In this example 2001:DB8:AC10:FE01 is the prefix (64 bits), and everything after it can be used for hosts.

In IPv4 we find the network address with the subnet mask. In IPv6 we can also calculate the prefix for any address, it just works a bit differently.

Example 1: /64

An IPv6 address that could be assigned to a host:

2001:DB8:AC10:FE01:21A:2BFF:FE3C:4D5E/64

Which part of this address is the prefix, and which part identifies the host?

2001DB8AC10FE0121A2BFFFE3C4D5EPrefix · first 64 bitsInterface ID (host) · 64 bitsPrefix: 2001:DB8:AC10:FE01::/64
Figure 1 · With /64 the address is split exactly in half: the first four groups are the prefix, the last four the interface ID

/64 means the first 64 bits are the prefix. Since each hex character is 4 bits:

  • 64 / 4 = 16 hex characters, which is the first four groups: 2001:0DB8:AC10:FE01.
  • The rest identifies the host (the interface ID): 021A:2BFF:FE3C:4D5E.

But simply writing the prefix as 2001:DB8:AC10:FE01 is not correct. To write the prefix correctly, we add zeros at the end to complete the address to 128 bits again and add the prefix length:

text
2001:0DB8:AC10:FE01:0000:0000:0000:0000/64

This is a valid prefix, but we can shorten it: the zero groups at the end are replaced by :::

2001:DB8:AC10:FE01::/64

This is the shortest way to write the prefix.

Example 2: a shortened address

2001:DB8::7:AB12:34CD:56EF:7890/64

Before we can see the prefix, we must write the address in full, because it has been shortened (there is a ::). Seven groups are visible, so :: replaces one zero group. We add the zeros to complete 128 bits:

text
2001:0DB8:0000:0007:AB12:34CD:56EF:7890/64

The prefix length is still 64 bits, so the first 16 hex characters are the prefix:

text
2001:0DB8:0000:0007

We add zeros at the end and the prefix length:

text
2001:0DB8:0000:0007::/64

That looks fine, but we can shorten it a little more: drop the leading zeros and 0000 → 0:

2001:DB8:0:7::/64

This is the shortest form of the prefix. Note: we can't replace 0:7 with ::, because :: is already used at the end and may appear only once.

When the prefix length is not a multiple of 16

Depending on the prefix length, the calculation is very easy or a bit harder. In the examples so far the prefix length was 64. What about /53?

9ABC1001101010111100HexBinary1 hex character = 4 bits · 1 group = 16 bits
Figure 2 · Each hexadecimal character is four bits. If the prefix length is a multiple of 16, the boundary falls between groups; a multiple of 4, between characters
Prefix lengthWhere the boundary isDifficulty
Multiple of 16 (/16, /32, /48, /64)Between groupsEasy
Multiple of 4 (/52, /56, /60)Between hex charactersMedium
Other (/53, /61 ...)Inside a hex characterBinary needed

Example 3: /53

2001:DB8:CAFE:9ABC:1111:2222:3333:4444/53

We want to find the prefix of this address. Where do we start?

2001DB8CAFE9ABC1111222233334444bits 49–641001101010111100/5310011000000000009ABC9800Host bits set to zero → prefix: 2001:DB8:CAFE:9800::/53
Figure 3 · /53: bit 53 is in the 4th group (bits 49–64). The first 5 bits of that group stay in the prefix, the rest are set to zero

Step 1: which group contains bit 53? Each group is 16 bits:

Group12345678
Bits1–1617–3233–4849–6465–8081–9697–112113–128
Value20010DB8CAFE9ABC1111222233334444

Bit 53 is in the 4th group (bits 49–64). The first three groups (48 bits) are fully in the prefix; from the 4th group, 53 − 48 = 5 bits stay in the prefix.

Step 2: convert that group to binary.

Hex9ABC
Binary1001101010111100

Step 3: keep the first 5 bits, set the remaining host bits to zero.

text
Before:  10011 | 01010111100
After:   10011 | 00000000000
         prefix   host (zeroed)

Step 4: convert back to hex.

Binary1001100000000000
Hex9800

Step 5: put the group back and set all following host bits to zero.

text
2001:0DB8:CAFE:9800:0000:0000:0000:0000/53

We found the prefix: 2001:DB8:CAFE:9800::/53. It's not hard to calculate, you just have to work with some binary.

Getting used to IPv6 addressing and finding prefixes takes some time, but the more you practise, the easier it becomes.

Check yourself

5 questions · answers are shown instantly · 3 correct answers complete the lesson

1What is the prefix of 2001:DB8:AC10:FE01:21A:2BFF:FE3C:4D5E/64?

/64 = the first 16 hex characters (four groups); the rest is set to zero.

2How many hex characters is a /64 prefix?

Each hex character is 4 bits: 64 / 4 = 16.

3What is the prefix of 2001:DB8::7:AB12:34CD:56EF:7890/64?

:: replaces one zero group: 2001:0DB8:0000:0007 is the prefix.

4With a /53 prefix, which group contains bit 53?

48 bits are the first three groups; bits 49–64 are in the 4th group.

5What is the prefix for 2001:DB8:CAFE:9ABC::1/53?

9ABC = 1001 1010 1011 1100; the first 5 bits 10011 stay → 1001 1000 0000 0000 = 9800.
Was this lesson useful?

Comments

Sign in to comment.