Network Fundamentals · Topic 16 of 17
IPv6 Addressing Practice: Shorten, Expand and Subnet
Worked IPv6 addressing problems with steps: shorten and expand addresses, spot invalid ones, count subnets in a /48 and place an address in its /64.
- 5 min
- Drop leading zeros only, and never trailing ones.
- Use
::once, for the longest run of zero groups. - A valid address expands to exactly eight groups of at most four hex digits.
What it is
IPv6 addressing is mostly rewriting and counting, and both are easy to get wrong without practice.
This page works through shortening, expanding, spotting invalid addresses and planning /64 subnets from a /48. Every answer shows its steps.
Work each one on paper first, then compare.
How it works
Shortening and expanding are the same two rules applied in opposite directions.
- Drop the leading zeros in every group.
- Replace one run of all-zero groups with
::. Use the longest run, and use::only once.
Problem 1: shorten 2001:0DB8:0000:0000:0042:0000:0000:0001
Dropping leading zeros gives 2001:DB8:0:0:42:0:0:1.
There are two runs of two zero groups, and they are the same length. By convention you replace the first one.
- Answer: 2001:DB8::42:0:0:1
- The other form, 2001:DB8:0:0:42::1, is also a valid address, but the usual convention is to replace the first run.
Problem 2: shorten 2001:0DB8:00A0:0000:0000:0000:0000:0100
Dropping leading zeros gives 2001:DB8:A0:0:0:0:0:100. The longest zero run is the four groups in the middle.
- Answer: 2001:DB8:A0::100
Problem 3: expand 2001:db8::1 and FE80::A:B
Count the groups that are shown, then fill the gap with zero groups until there are eight, and pad every group to four digits.
- 2001:db8::1 shows 3 groups, so 5 are missing: 2001:0db8:0000:0000:0000:0000:0000:0001
- FE80::A:B shows 3 groups, so 5 are missing: FE80:0000:0000:0000:0000:0000:000A:000B
Problem 4: which of these are invalid?
| Address | Valid? | Reason |
|---|---|---|
| 2001:DB8::1::2 | No | :: appears twice |
| 2001:DB8:G::1 | No | G is not a hexadecimal digit |
| 2001:DB8:0:0:0:0:0:0:1 | No | Nine groups, the maximum is eight |
| 2001:DB8:12345::1 | No | A group has five digits, the maximum is four |
| 2001:DB8::1 | Yes | One ::, valid groups |
Trailing zeros are never dropped. The group 0100 shortens to 100, not to 1.
Problem 5: subnets from 2001:DB8:ACAD::/48
A /48 leaves 16 bits, the fourth group, between the /48 and the /64 boundary. That is the subnet ID.
- Number of /64 subnets: 2 to the power 16 is 65,536
- Subnet ID written as the VLAN number in hex: VLAN 10 is A, so 2001:DB8:ACAD:A::/64
- VLAN 100 is 64 in hex, so 2001:DB8:ACAD:64::/64
- VLAN 255 is FF, so 2001:DB8:ACAD:FF::/64
Many designs reuse the decimal digits instead, so VLAN 100 becomes 2001:DB8:ACAD:100::/64. Either is valid if the plan is consistent.
Problem 6: which /64 is this address in?
The address 2001:DB8:ACAD:7:50::1 has the first four groups 2001:DB8:ACAD:7, so it is in 2001:DB8:ACAD:7::/64.
The addresses 2001:DB8:ACAD:7::10 and 2001:DB8:ACAD:8::10 differ in the fourth group, so they are in different subnets and need a router.
Problem 7: how many /64 subnets?
Each step of 4 bits in the prefix gives 16 times as many subnets.
- A /56 holds 2 to the power 8, which is 256 /64 subnets.
- A /60 holds 2 to the power 4, which is 16 /64 subnets.
Problem 8: address a host in VLAN 20
Using the same plan with hex subnet IDs, VLAN 20 is 14 in hex, because 20 is 16 plus 4.
The subnet is 2001:DB8:ACAD:14::/64. A host with interface ID 5 is 2001:DB8:ACAD:14::5/64, and its gateway on that subnet might be 2001:DB8:ACAD:14::1.
Putting it on a router
interface Vlan10
ipv6 address 2001:DB8:ACAD:A::1/64
ipv6 address FE80::1 link-local
show ipv6 interface brief
Vlan10 [up/up]
FE80::1
2001:DB8:ACAD:A::1
Count groups first. A valid address always has eight groups after the :: is expanded, so if the numbers do not add up, the address is invalid.
What to remember for the exam
Six rules cover most of this practice.
- Drop leading zeros only, and never trailing ones.
- Use
::once, for the longest run of zero groups. - A valid address expands to exactly eight groups of at most four hex digits.
- In a /48 site prefix, the fourth group is the subnet ID for /64 subnets.
- A /48 holds 65,536 /64 subnets, a /56 holds 256 and a /60 holds 16.
- Two addresses are in the same /64 only if their first four groups match.
Common mistakes
These four slips come up most.
Using :: twice. The address then has no single meaning.
Dropping trailing zeros. 0100 and 1 are different numbers.
Counting the wrong bits. The number of /64 subnets comes from the bits between the allocated prefix and /64.
Mixing up hex and decimal in the subnet ID. VLAN 100 is 64 in hex, but a design may also write it as 100.
Check yourself
Try these three, then click a question to reveal its answer.
How is 2001:0DB8:0000:0001:0000:0000:0000:0001 shortened?
2001:DB8:0:1::1.
How is FF02::2 written in full?
FF02:0000:0000:0000:0000:0000:0000:0002.
How many /64 subnets are in a /52?
4,096, because 12 bits lie between /52 and /64.
Topic 16 of 17 in Network Fundamentals
Test yourself on Network Fundamentals
The full Cisco CCNA 200-301 question bank has 1,206 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Cisco. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.