Skip to content

IPv6 in 55 minutes

Exercise ipv6-in-55-minutes-annex.pdf · PDF

Pick up your phone, switch off the Wi-Fi and look at its network details on mobile data. There is a good chance you will find an address that looks nothing like 192.168.1.35. Something like 2a0c:5a80:1f02:6b00::1d. Letters, colons, a double colon in the middle. What is that?

It is an IPv6 address, and your phone has probably used one every day for years. On Wednesday you saw that NAT exists because the world ran out of IPv4 addresses. NAT is a patch. Today you meet the real repair, and it has been ready since before you were born.

What you will learn

  • Explain why IPv4 ran out and what 128 bits change
  • Shorten and expand an IPv6 address with the two writing rules
  • Recognise loopback, link-local, global, unique local and multicast addresses by their first digits
  • Describe SLAAC: how a PC builds its own address without any DHCP server
  • Read ip -6 addr, ip -6 route and ip -6 neigh, and test with ping and traceroute
  • Why 128 bits is not four times more than 32, and why ping fe80::1 fails without %eth1

Why IPv4 ran out

An IPv4 address has 32 bits. That gives 2³² ≈ 4.3 billion addresses: fewer than there are people on Earth, and each person now carries a phone, a laptop, a console, a smartwatch...

The registries that hand out addresses ran dry, one after another:

Date What happened
December 1998 Steve Deering and Bob Hinden publish IPv6 as RFC 2460 (today's text is RFC 8200, July 2017)
3 February 2011 IANA, the world's central registry, hands out its last blocks of IPv4
25 November 2019 RIPE NCC, the registry for Europe, gives away its very last IPv4 block

IPv6 (Internet Protocol version 6) is the successor of IPv4. Its addresses have 128 bits: 2¹²⁸ ≈ 3.4 × 10³⁸ addresses.

How much bigger is that? Four times, because 128 = 4 × 32? No. Every extra bit doubles the number of addresses. 96 extra bits double it 96 times: IPv6 has 2⁹⁶ times more addresses than IPv4. That is enough to give a whole network to every grain of sand you can imagine.

And it is not the future. In 2026 about half of the people who use Google reach it over IPv6.

Careful: IPv6 is not IPv4 with more digits

They are two separate protocols. A host usually runs both at once — this is called dual stack — with two sets of addresses and two routing tables. ip -br addr on your PC shows both kinds side by side.

Writing an IPv6 address

128 bits in binary would be a wall of 128 zeros and ones. So IPv6 is written in hexadecimal (the hex you used for MAC addresses): 8 groups of 4 hex digits, separated by colons. Each group is 16 bits.

2001:0db8:0000:0000:0000:ff00:0042:8329

Still long. Two rules make it shorter:

2001:0db8:0000:0000:0000:ff00:0042:8329   8 groups of 4 hex digits
2001:db8:0:0:0:ff00:42:8329               rule 1: drop leading zeros
2001:db8::ff00:42:8329                    rule 2: ONE run of zero groups = ::

Rule 1 — drop the leading zeros. Zeros at the left of a group can go: 0042 → 42, 0db8 → db8, 0000 → 0. Zeros at the right stay: ff00 is not ff. ff00 and 00ff are different numbers.

Rule 2 — one ::. One run of consecutive all-zero groups can be replaced by ::. Only once per address: with two :: nobody could tell how many zeros each one hides. If there are two runs, shorten the longest; if they tie, the first one. Letters are written in lowercase (RFC 5952).

To expand an address, count the groups you can see. The :: stands for all the missing ones, up to 8.

Short form Groups you see :: hides Full form
2001:db8::1 3 5 2001:0db8:0000:0000:0000:0000:0000:0001
fd00:5::20 3 5 fd00:0005:0000:0000:0000:0000:0000:0020
::1 1 7 0000:0000:0000:0000:0000:0000:0000:0001

The street and the house number (we keep it all page)

An IPv6 address works like a postal address with two halves. The first 64 bits are the street name: the network. The last 64 bits are the house number: one interface on that street. The prefix length works like in IPv4: /64 means "the first 64 bits name the network". In IPv6, a LAN is always a /64.

Kinds of address: read the first digits

In IPv4 you learnt to spot 10.x.x.x or 127.0.0.1 at a glance. IPv6 has the same trick: the first digits tell you the kind.

Starts with Type What it is for IPv4 cousin
::1 Loopback The machine itself 127.0.0.1
fe80: Link-local Automatic, on every interface; only works on that cable —
2 or 3 Global Public Internet address A public address
fc or fd Unique local Private, never on the Internet 10.x.x.x
ff Multicast A group of machines; ff02::1 = everybody on this cable —

Some examples:

  • fe80::a8c1:abff:fe92:d27f — link-local.
  • 2a04:4e42::644 — global (it is one of the addresses of debian.org).
  • fd00:5::20 — unique local.
  • ff02::1 — multicast, all nodes on the link.

Careful: the lab addresses are not Internet addresses

In the lab you will see 2001:db8:... and fd00:.... 2001:db8::/32 is reserved for documentation and labs: it is never routed on the Internet. fd... is unique local, private like 10.x.x.x. We use both on purpose.

Careful: a global IPv6 address is public

At home, your IPv4 address is private and NAT hides it. A global IPv6 address is public: there is normally no NAT in IPv6. What protects your LAN is the firewall you met yesterday.

SLAAC: the PC picks its own house number

With IPv4, a PC switches on and asks: "can somebody give me an address?" A DHCP server lends one and keeps a table of leases. IPv6 can work differently.

sequenceDiagram
    participant PC as PC
    participant R as Router
    Note over PC: 1. builds a link-local address<br>fe80::... by itself
    R->>PC: 2. Router Advertisement to ff02::1<br>"the street here is 2001:db8:10::/64,<br>and I am the way out"
    Note over PC: 3. prefix (64 bits) + its own 64 bits<br>= global address + default route
  1. The PC switches on and gives itself a link-local address fe80::.... Nobody is asked. It only works on that cable.
  2. The router shouts to everybody on the cable (multicast ff02::1) a Router Advertisement (RA): "the network here is 2001:db8:10::/64, and I am the way out".
  3. The PC takes those 64 bits, adds 64 bits of its own, and now has a global address and a default route.

SLAAC (Stateless Address Autoconfiguration, RFC 4862) is the way an IPv6 host builds its own global address from the prefix that the router advertises.

"Stateless" means the router remembers nothing: no DHCP server, no table of leases. In the analogy: the router announces the street name, and every PC picks its own house number.

One more difference. IPv6 has no broadcast and no ARP. To find a neighbour's MAC address, hosts send multicast messages called Neighbour Discovery. ip -6 neigh is the new ip neigh.

Careful: one interface, several addresses

In IPv4 you think "one host, one address". In IPv6 an interface normally has several: always one link-local, plus one or more global ones.

Your addresses in the lab

The lab is the office topology: pc1 and pc2 behind the router r1, and the server srv on the other side. r1 sends Router Advertisements. Nobody typed an IPv6 address on pc1. Follow the Exercise sheet.

cd ~/lab/office && containerlab deploy -t office.clab.yml
docker exec -it clab-office-pc1 bash
ip -6 addr show dev eth1

Real output from the lab (first line shortened; the last 64 bits differ on every machine):

12: eth1@if11: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9500 ... state UP
    inet6 2001:db8:10:0:a8c1:abff:fe92:d27f/64 scope global dynamic
          mngtmpaddr proto kernel_ra
       valid_lft 86395sec preferred_lft 14395sec
    inet6 fe80::a8c1:abff:fe92:d27f/64 scope link proto kernel_ll
       valid_lft forever preferred_lft forever

How to read it:

  • scope link ... kernel_ll — the link-local address, made by the kernel itself.
  • scope global dynamic ... kernel_ra — the global address, built from a Router Advertisement. It has a lifetime (valid_lft) that the router keeps renewing.
  • Both addresses end with the same 64 bits: the same house number on two different streets.

The way out.

ip -6 route

You will see a line like default via fe80::... dev eth1 proto ra. The gateway is the router's link-local address, learnt from the advertisement.

The neighbours.

ping -c 2 ff02::1%eth1
ip -6 neigh

The ping to "everybody on this cable" is answered by two addresses: pc1 itself and r1. ip -6 neigh then lists r1 with its MAC address and the word router.

Why %eth1? A link-local address exists on every interface, all of them starting with fe80::. So the kernel must be told which cable you mean. Without %eth1 the ping fails.

Crossing the router.

ping -c 2 2001:db8:ffff::10
traceroute -n 2001:db8:ffff::10
dig +short AAAA intranet.tramuntana.internal

The ping works; traceroute shows two hops (2001:db8:10::1, the router, then the server); dig returns 2001:db8:ffff::10. An AAAA record is the IPv6 version of the DNS A record: four A's because the address is four times as long in bits.

When you finish: exit, then containerlab destroy -t office.clab.yml --cleanup.

Why the house number looks familiar

Compare the MAC address of eth1 (ip -br link) with the last 64 bits of the link-local address. The MAC is inside, split in two with ff:fe in the middle (and one bit flipped in the first byte). Phones and laptops use random numbers instead, so nobody can follow them from network to network by their MAC.

Stretch, on the group's MikroTik. Add a unique local prefix to the LAN bridge and let the router advertise it (G = your group number):

/ipv6 address add address=fd00:G::1/64 interface=bridge-lan advertise=yes

Within a few seconds, ip -6 addr on a PC cabled to it shows a new fd00:G:... address. In WinBox: IPv6 → Addresses → +.

Key takeaways

  • IPv4 has 32 bits (about 4.3 billion addresses) and ran out; IPv6 has 128 bits, 2⁹⁶ times more. Most hosts run both: dual stack.
  • An IPv6 address is 8 groups of 4 hex digits. Rule 1: drop leading zeros. Rule 2: one run of zero groups becomes ::, only once.
  • A LAN is always a /64: the first 64 bits are the network (the street), the last 64 the interface (the house number).
  • First digits tell the kind: ::1 loopback, fe80: link-local, 2/3 global, fc/fd unique local, ff multicast.
  • With SLAAC the router sends a Router Advertisement with the prefix and the host builds the rest; no DHCP server, no leases.
  • No broadcast, no ARP: Neighbour Discovery (ip -6 neigh). A link-local address needs the interface: ping fe80::1%eth1.

Quick check

1. Which is the correct short form of 2001:0db8:0000:0000:000a:0000:0000:0001?
  • 2001:db8::a:0:0:1
  • 2001:db8::a::1
  • 2001:db8::a:0:0:1:0
  • 2001:db8:0:0:a::1:0

There are two runs of two zero groups. Rule 2 allows only one ::, and when the runs tie you shorten the first. :: twice is forbidden because nobody could rebuild the address; the other two forms have the wrong number of groups.

2. How many times more addresses does IPv6 have than IPv4?
  • 2⁹⁶ times more
  • 4 times more
  • 96 times more
  • 128 times more

IPv6 has 128 bits and IPv4 has 32. Every extra bit doubles the count, and there are 96 extra bits: 2¹²⁸ ÷ 2³² = 2⁹⁶. That is about 3.4 × 10³⁸ addresses in total.

3. An address starts with fe80::. What is it?
  • A link-local address, valid only on that cable
  • A public address on the Internet
  • A private address like 10.x.x.x
  • A multicast group

fe80: means link-local: the host builds it by itself on every interface, and it only works on that link. Private (unique local) addresses start with fc or fd; multicast with ff; global with 2 or 3.

4. With SLAAC, how does a PC get its global address?
  • The router advertises the prefix and the PC builds the rest
  • A DHCP server lends it a whole address for a lease time
  • The user types it by hand in the settings
  • The PC copies its IPv4 address into the last bits

In SLAAC the router sends a Router Advertisement with the /64 prefix (the street), and the PC adds 64 bits of its own (the house number). It is stateless: the router keeps no table of leases.

5. ping fe80::1 fails with an error, but the router is there. What is missing?
  • The interface, as in fe80::1%eth1
  • A DNS server for the name
  • The prefix length /64
  • A default gateway

Every interface has a link-local address starting with fe80::, so the kernel cannot guess which cable you mean. You must add the interface with %: ping fe80::1%eth1.

6. On pc1, ip -6 route shows the default gateway. What kind of address is it?
  • The router's link-local address, learnt from its advertisement
  • The router's global address, typed by the administrator
  • The multicast address ff02::1
  • The loopback address ::1

The line reads default via fe80::... dev eth1 proto ra: the gateway is the router's link-local address, and proto ra says it came from a Router Advertisement.

7. Your phone on mobile data has the global IPv6 address 2a0c:5a80:1f02:6b00::1d. Select the two that are true.
  • It is a public address, reachable from the Internet unless a firewall blocks it
  • The phone may also have an IPv4 address at the same time
  • It is private, because NAT always hides IPv6 addresses
  • It must have been typed by hand, because IPv6 has no automatic addresses

An address starting with 2 is global, and IPv6 normally uses no NAT: the firewall is what protects you. Most devices run dual stack, with IPv4 and IPv6 side by side. And addresses are automatic thanks to SLAAC.

Next: when something stops working, you need a method, not luck — Network troubleshooting.