Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
IP Addressing  ›  Lesson

IPv4 vs IPv6

IPv4 vs IPv6 15 minIPv4 addresses are 32 bits written as four decimal numbers, while IPv6 addresses are 128 bits written as eight hexadecimal groups that can be shortened.

IPv4 vs IPv6

Kite Studio's router shows two kinds of address for Asha's laptop: the familiar 192.168.10.57, and something much longer, 2001:db8:4a:10::57. The first is IPv4, designed in an age when a few billion addresses sounded endless. The second is IPv6, built because the world ran out.

The rule

IPv4 is 32 bits in four decimals; IPv6 is 128 bits in eight hex groups.

IPv4 addresses are 32 bits, written as four numbers from 0 to 255 separated by dots: 192.168.10.57. Each number is one byte, called an octet. That gives 2322^{32}, about 4.3 billion addresses — fewer than the number of phones, laptops and servers on earth. The shortage is why private addresses and NAT (the next two lessons) became universal.

IPv6 addresses are 128 bits, written as eight groups of four hex digits separated by colons. That gives 21282^{128}, about 3.4×10383.4 \times 10^{38} addresses — enough to give every device its own public address with room to spare. Other differences worth knowing:

  • IPv6 has no broadcast; it uses multicast to reach groups of hosts instead.
  • Hosts can configure their own address from the router's advertised network prefix (SLAAC), with or without DHCPv6.
  • The header is simpler and fixed at 40 bytes, and NAT is not normally needed.
  • Most networks today run both side by side, called dual stack.

Writing IPv6 short. Long addresses are shortened with two rules:

  1. Drop leading zeros in any group: 0db8 → db8, 0000 → 0.
  2. Replace one run of consecutive all-zero groups with ::. Only once per address, or it would be impossible to know how many zeros each :: stands for.

2001:db8:: is a special prefix reserved for documentation, which is why the examples here use it.

The shortcut

Shorten in a fixed order: strip leading zeros first, then squash the longest zero run into ::. To expand, count the groups you can see and fill the :: with however many 0 groups make eight.

Shortening Asha's full IPv6 addressStep 1 of 4
  1. Start with the full form

    2001:0db8:004a:0010:0000:0000:0000:0057

The trap is using :: twice, as in 2001::4a::57. Nobody could tell how many zero groups belong in each gap, so it is invalid.

Drills

Answer fast — trust the rule.

quick drill

How many bits are in an IPv6 address?

quick drill

Which is a valid IPv4 address?

quick drill

What is the shortest correct form of 2001:0db8:0000:0000:0000:0000:0000:0001?

quick drill

How many zero groups does :: stand for in fe80::1:2?

quick drill

Which feature does IPv6 NOT have?

Remember

  • IPv4 is 32 bits in four decimals; IPv6 is 128 bits in eight hex groups.
  • Shorten IPv6: strip leading zeros, then one :: for the longest zero run.
  • To expand, :: fills 8 minus the visible groups.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainShorten and compare

Shorten 2001:0db8:0000:0000:0000:0000:0000:0042 step by step, explain why :: may appear only once, and give two ways IPv6 differs from IPv4 besides address length.