Labs / IP Addressing & NAT / IPv6

Lab 1 of 3 · IPv6

IPv6 explained: a network that sets itself up

See how IPv6 machines build their own addresses and reach the internet without NAT.

Start this lab 7 steps

The idea

Pine Street Library's reading room runs on IPv6, and nobody typed an address into any of its machines. Find out how each one gets its addresses, finds its neighbors and reaches the internet with no NAT in the way.

Two addresses, two reaches
Two addresses, two reaches
One ping, four answers
One ping, four answers
Four packets to a working address
Four packets to a working address
An address in two parts
An address in two parts
Asking one group
Asking one group
Only IPv4 gets rewritten
Only IPv4 gets rewritten
Answers pass, strangers stop
Answers pass, strangers stop

Steps

  1. Read a card's addresses

    Every machine on a network needs an address, and the internet has run out of the old kind. An IPv4 address such as 10.0.1.10 is 32 bits long, where a bit is a single 0 or 1. That allows about 4.3 billion addresses, and the central pool of them ran out in 2011.

    IPv6 is the replacement: version 6 of the Internet Protocol, the rules every piece of data follows across the internet. Its addresses are 128 bits long, which allows so many that running out stops being a concern. In June 2026, about half of the people using Google reached it over IPv6.

    You're at frontDesk, a computer in Pine Street Library's reading room. These machines exist only for this lab, so nothing you do here can hurt anything real.

    Ask frontDesk which IPv6 addresses its network card holds, by typing the command in its terminal, the window where you type commands to a machine. A network card is the part of a machine that connects it to a network, and this lab names each card after its network.

    frontDesk:~# ip -6 addr show dev readingRoom
  2. Call every machine in the room

    The fe80:: address is a link-local address. A link is a stretch of network where machines reach each other directly, with no Router in between: here, the reading room. A router is a machine that passes data between networks.

    Every IPv6 card builds a link-local address for itself the moment it comes up, so machines on a link can talk before anything else works. Routers never pass these addresses on, which is why every network in the world can use the same fe80:: block with no clash.

    Next, how do you reach everyone at once? IPv4 has a broadcast address that every machine on a network has to read. IPv6 dropped it, since each broadcast interrupts machines that have no interest in it.

    IPv6 uses Multicast instead: an address for a group, which a card joins when it wants that kind of message. A card that never joined drops the data, so its machine never has to read it.

    One group holds every IPv6 card from the start: ff02::1, all the machines on this link. %readingRoom after the address names the card to send from, because an ff02:: address means nothing until you pick a link.

    ping sends a small packet, one chunk of data on a network, and asks for an answer. catalog's link-local address ends in 114. After you've called the group, ping catalog: first with no card name, then with one.

    frontDesk:~# ping -w 1 ff02::1%readingRoom
    frontDesk:~# ping -w 1 fe80::42:aff:fe00:114
    frontDesk:~# ping -w 1 fe80::42:aff:fe00:114%readingRoom
  3. Let a machine build its address

    So where did those addresses come from? On IPv4, a new machine usually asks a DHCP server, which hands out an address and keeps a list of who has what. That list is one more machine to run, and one more thing to go wrong.

    IPv6 was designed so that a machine could set itself up. A router tells the machine the network's half of the address, and the machine makes the other half alone. Nobody keeps a list, so the method is called stateless address autoconfiguration (SLAAC).

    Watch it happen on newTerminal. The lab turns its card off, which wipes its IPv6 addresses.

    Bring the card up while the lab records at libraryRouter. Then read the address it ended up with, and the routes it learned.

    newTerminal:~# ip link set dev readingRoom up
    newTerminal:~# ip -br addr show dev readingRoom
    newTerminal:~# ip -6 route
  4. Find the MAC inside the address

    The router supplied the first half of newTerminal's address. The machine had to invent the second half, and it needed a number that no other card on the link would pick.

    It already had one. A MAC address is the number fixed into a network card when it's made, and it's meant to be unique in the world. The original SLAAC recipe stretches this 48-bit number to fill the 64 bits on offer:

    1. Cut the MAC in half and put ff:fe in the middle.
    2. Flip one bit in the first pair of digits, which turns 02 into 00 here, and 00 into 02 on a card from a factory.

    The result is called a modified EUI-64 identifier. Check the recipe on two real cards: ip link show prints a card's MAC after link/ether. Compare each with the address that ends in the same digits: 11e for newTerminal and 114 for catalog.

    newTerminal:~# ip link show dev readingRoom
    catalog:~# ip link show dev readingRoom
  5. Find a neighbor without ARP

    An address alone can't deliver data across a link. Network cards send to each other by MAC address, so before frontDesk can reach catalog, its neighbor on the same link, it has to learn catalog's MAC.

    On IPv4, ARP does that by asking everyone: a broadcast that says "who has this address?", which every machine on the network has to read. On a network of thousands, that's a lot of machines interrupted for a question meant for one of them.

    IPv6 has Neighbor Discovery for this job, and it doesn't ask everyone.

    The lab clears frontDesk's list of neighbors, so that it has to ask. Ping catalog's global address while the lab records at catalog. Then read two lists: the neighbors frontDesk knows now, and the groups catalog has joined.

    ip -6 maddr only takes a card's first name, so that one command says eth0.

    frontDesk:~# ping -c 1 2001:db8:50:1:42:aff:fe00:114
    frontDesk:~# ip -6 neigh show dev readingRoom
    catalog:~# ip -6 maddr show dev eth0
  6. Leave the room with no NAT

    Time to leave the room. Data for another network goes to the default gateway, libraryRouter, and what the router does with it depends on the IP version.

    On IPv4, frontDesk is 10.0.1.10, a private address that no router on the internet will carry. So libraryRouter runs NAT: it swaps that sender for its own public address, 198.51.100.2, on the way out. NAT arrived in the 1990s as a short-term fix, so that a whole building could share one public address.

    On IPv6 there's no shortage to work around. frontDesk's 2001:db8:50:1 address is public, so the router passes the packet along and leaves the sender as it is.

    cityArchive is a website outside the room, and its page prints the sender it saw. Fetch the page both ways. In a web address, an IPv6 address goes inside square brackets, because a colon there normally comes before a port number, as in :8080.

    Then go to cityArchive and ping frontDesk from outside.

    frontDesk:~# curl -sS -m 3 http://198.51.100.50/
    frontDesk:~# curl -sS -m 3 http://[2001:db8:50:2::50]/
    cityArchive:~# ping -c 1 -w 1 2001:db8:50:1:42:aff:fe00:10a
  7. Stop strangers at the router

    That ping from outside should worry you. If cityArchive can reach frontDesk, so can anyone on the internet.

    NAT was never built as a lock, but it acted like one. A distant stranger had no way to name a machine behind it, so machines inside were out of reach by accident.

    IPv6 takes that accident away. A public address means that a machine can be found, and it doesn't have to mean that strangers get through.

    Stopping them is the job of a Firewall, which decides which packets may pass. The usual rule for a home or an office is this: whatever starts inside may go out, and whatever starts outside stops at the router. Many home routers do this for IPv6 out of the box, as RFC 6092 recommends, but it's worth checking yours.

    The router has to tell an answer from a stranger. It does that with connection tracking: it keeps a note of each conversation passing through, so it knows which packets belong to one already running.

    ip6tables is Linux's firewall tool for IPv6, and it's separate from iptables, which handles IPv4 only. The dual-stack lab shows what happens when someone forgets that.

    Add the rule on libraryRouter. Then call frontDesk from outside again, and fetch the page from frontDesk.

    libraryRouter:~# ip6tables -v -A FORWARD -d 2001:db8:50:1::/64 -m conntrack --ctstate NEW -j DROP
    cityArchive:~# ping -c 1 -w 1 2001:db8:50:1:42:aff:fe00:10a
    frontDesk:~# curl -sS -m 3 http://[2001:db8:50:2::50]/

Run these steps on real machines

Keep reading

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab