← All coursesBack to the simulator →

IPv6: after the addresses ran out

IPv4 addresses ran out and NAT is only a patch. What an IPv6 address looks like and how to read it, why /64 is everywhere, how a device builds its own address, why you still need a firewall without NAT, and what happens when nobody in a company watches IPv6.

This is a text preview of the lessons for reading. The full version – an interactive simulator with animations, exercises and quizzes – runs in the app.

▶ Launch the interactive version

Lesson 1: Why it exists and what it looks like

The addresses ran out

PCSWRINTERNETPHONESERVERLAPTOPIPv4: 32 bits = a little over 4 billion addresses

The whole internet stands on addresses, and IPv4 has only a little over four billion of them. When it was designed, that looked inexhaustible. Then came smartphones, home routers, cameras and the cloud, and the free blocks gradually ran out: the central pool was handed out in 2011 and the European registry exhausted its own in 2019.

The patch is NAT, which hides a whole household behind one public address. It works, but it sidesteps the problem: you cannot reach a device directly from outside, and providers today often put whole groups of customers behind one address.

IPv6 fixes the cause: it has so many addresses that running out stops being a topic. One note up front: the simulator works with IPv4, so this course is explanatory, with no tasks on the canvas. The routing, firewall and DNS principles you know still apply.

Step by step

  1. IPv4 has 32 bits. Four billion addresses for the whole planet once looked like plenty.
  2. But devices multiplied faster. The free public blocks ran out.
  3. NAT hides a network behind one public address. It saved IPv4, but it is a patch, not a solution.
  4. IPv6 has 128 bits. Every device can have a public address and communicate without translation.

How an address is written

PCSWRINTERNETPHONESERVERLAPTOPIPv4: 192.168.1.10

An IPv4 address is four decimal numbers. IPv6 would be unreadable in that notation, so it is written in hexadecimal: every digit carries four bits, using the characters 0–9 and a–f. An address has eight groups of four digits separated by colons, for example 2001:0db8:0000:0012:0000:0000:0000:0001.

A group has 16 bits, and eight times sixteen makes 128. The difference from IPv4 is not two or four times more addresses: 128 bits is 2128, a number with thirty-nine digits. Every extra bit doubles the space, and 96 bits were added. Colons replace the dots here, and in links an address goes in square brackets so it is not confused with a port: http://[2001:db8::1]:8080.

The examples in this course use the range 2001:db8::/32, which is reserved for documentation and is not routed on the internet.

Step by step

  1. IPv4: four decimal numbers separated by dots, 32 bits in total.
  2. IPv6: eight groups of four hexadecimal digits, separated by colons.
  3. Each group has 16 bits, 128 in total. That is 96 bits more than IPv4, and each one doubles the space.
  4. In a link the address goes in square brackets, otherwise the colon would clash with the port.

Shortening addresses

PCSWRINTERNETPHONESERVERLAPTOP2001:0db8:0000:0012:0000:0000:0000:0001

Nobody wants to keep writing 39 characters, which is why there are two shortening rules. First: within a group you may drop leading zeros, so 0db8 becomes db8 and 0012 becomes 12. Trailing zeros stay. Second: one continuous run of all-zero groups may be replaced with a double colon ::.

Just one: with two of them you could not tell how many zeros belong in which gap. When there are several runs, the longest one is shortened. The long address from the previous module becomes 2001:db8:0:12::1. Careful when reading: ::1 stands for seven zero groups and a one at the end, and it means the same as 127.0.0.1, that is, this computer.

The same address can be written several ways, so when you compare addresses in a log or a firewall rule, compare the value, not the text.

Step by step

  1. We start from the full form. All eight groups, 39 characters.
  2. Rule 1: drop the leading zeros in each group. 0000 becomes 0.
  3. Rule 2: the longest run of zeros becomes ::. Here, the three groups after the 12.
  4. Two :: in one address are invalid. You could not tell how many zeros belong in which gap.

▶ Open in the simulator

Lesson 2: Kinds of addresses and networks

Link-local, global and ULA

PCSWRINTERNETPHONESERVERLAPTOPlink-local: fe80::… local network only

A device with IPv6 does not have one address but commonly several at once, and each has a different reach. Link-local starts with fe80 and is valid only on one cable or in one network behind a switch. A router will not forward it. Every device creates it by itself right after power-on, so neighbors can talk even without a router.

A global address today starts with 2 or 3 (for example 2001:…) and is valid across the internet; it is the counterpart of a public IPv4 address. ULA starts with fd and is the counterpart of the private ranges: it is used inside a company and is not routed on the internet.

So the start of an address tells you its reach at once. A link-local address is not forwarded by a router, so it cannot arrive from the internet. Your provider’s router does talk to you from fe80, though, so do not block it wholesale on the outside interface.

What is suspicious is a packet with such a source that would have to be forwarded. And beware an IPv4 habit: a private address is not a necessity in IPv6. An ordinary network does fine with a link-local and a global address.

Step by step

  1. Devices create a link-local address by themselves. It is enough for neighbors on the same network.
  2. Link-local ends at the router. That is why it never arrives from the internet.
  3. A global address reaches the internet, just like a public IPv4 address.
  4. ULA suits internal services. It is the counterpart of the private ranges, but it is not mandatory.

Why /64 is everywhere

PCSWRINTERNETPHONESERVERLAPTOPprovider: 2001:db8:abcd::/48

The slash means the same as in IPv4: how many bits from the left belong to the network. In the course Splitting a network: subnets in practice you learned to work out how many addresses you need. With IPv6 that task flips. An ordinary network always uses /64: half of the address identifies the network and the other half the device.

A single /64 could hold 264 devices, so the question “will everything fit?” disappears and nobody calculates /26 or /27 masks. Automatic address configuration also counts on a /64 directly. Planning therefore moves up a level: the provider allocates a larger block, often a /56 for a home and perhaps a /48 for a company, and you carve individual /64s out of it.

A /56 gives 256 networks and a /48 gives 65,536. The fourth group of the address then tells you which network it is: 2001:db8:abcd:12::/64 could be the warehouse. The broadcast address is gone too, so subtracting two is a thing of the past.

Step by step

  1. The provider allocates a block, here a /48. That is 65,536 networks under your control.
  2. Every network gets a /64. The fourth group says which one it is, the warehouse for example.
  3. Anything fits in a /64. The question “how many addresses do I need” vanishes for a single network.
  4. Planning gets simpler: how many networks you need, not how many addresses fit in each.

No broadcast: multicast and anycast

PCSWRINTERNETPHONESERVERLAPTOPIPv4 broadcast: everyone must process it

In IPv4 a broadcast is a message for everyone on the network, and every device must process it even when it does not concern them. IPv6 has no broadcast at all. It uses multicast instead: a message for a group that devices join. Group addresses start with ff. ff02::1 means all devices on the local network and ff02::2 all routers.

The benefit is that a question for routers is processed only by routers, and the printer does not have to wake up. A good switch can also send such traffic only where someone wants it. The second new term is anycast: several servers hold the same address and traffic reaches the nearest one.

That is how large public DNS services work, for example. Anycast exists in IPv4 too, but in IPv6 it is part of the design. You will see the difference right in the next lesson: neighbor discovery runs over multicast.

Step by step

  1. An IPv4 broadcast disturbs everyone on the network, even when it does not concern them.
  2. Multicast targets a group. A message for routers is processed by routers only.
  3. When everyone must be addressed, there is the ff02::1 group. It is a choice, not the default.
  4. Anycast: several servers share an address and traffic reaches the nearest one.

▶ Open in the simulator

Lesson 3: How a device finds the network

NDP instead of ARP

PCSWRINTERNETPHONESERVERLAPTOPI need the MAC for 2001:db8::20

To send data to a neighbor you need their MAC address. In IPv4, ARP asks for it by broadcast. IPv6 has no broadcast, so NDP (Neighbor Discovery Protocol), which runs over ICMPv6, solves the same thing. The asker sends a Neighbor Solicitation: “who has this address?”.

It does not go to everyone, though. It targets a special multicast group derived from the last 24 bits of the address being looked up, so only a handful of devices process it, typically just one. The owner replies with a Neighbor Advertisement carrying its MAC address.

The result lands in the neighbor table, just like an ARP table. One caution: NDP has the same weakness as ARP. Nobody verifies the reply, so an attacker on the network can claim someone else’s address. In principle it is the same attack as the ARP spoofing from the course The switch in depth, just on a new protocol.

Step by step

  1. The PC wants to talk to a server on the same network and needs its MAC address.
  2. The Neighbor Solicitation goes by multicast to a group based on the target address, not to everyone.
  3. The server replies with a Neighbor Advertisement. The PC stores the result in its neighbor table.
  4. Nobody verifies the reply, so it can be forged just like ARP. The weakness stayed.

SLAAC: an address without a server

PCSWRINTERNETPHONESERVERLAPTOPRouter Solicitation: is there a router?

In IPv4 you get an address from a DHCP server, as you know from the course DHCP: how a device gets an address. IPv6 can do something more: the device assembles its address itself. The procedure is called SLAAC. After connecting, it creates a link-local address and sends a Router Solicitation: “is there a router here?”.

The router replies with a Router Advertisement, stating which prefix applies on the network and that it is the default gateway. The router also sends this message by itself at regular intervals. The device generates the second half of the address for the prefix and then checks that nobody is using it; this is called DAD, duplicate address detection.

Ordinary end devices now pick the second half at random. An older method built it from the MAC address, but that would let a device be tracked across networks. No server keeps a record here, so you have to look for devices some other way than in a lease list.

Step by step

  1. The phone connects, has a link-local address and asks: is there a router here?
  2. The router answers with a Router Advertisement: this prefix applies here and I am the gateway.
  3. The phone generates the second half at random. No server assigns it.
  4. Before using the address, it checks via DAD that nobody else holds it.

DHCPv6 and the AAAA record

PCSWRINTERNETPHONESERVERLAPTOPRA: SLAAC is enough, or ask the server

SLAAC gives a device an address and a gateway, but a company often wants more: the address of a DNS server, an overview of who has which address, or a fixed address for a particular machine. That is what DHCPv6 is for. In each RA the router hints (the M and O flags) at what the device should do.

Either SLAAC is enough, or the address should be requested from a DHCPv6 server, or the device builds its own address and takes only additional details from the server, such as DNS. The device always learns the gateway from the RA, though: unlike in IPv4, DHCPv6 does not hand it out.

DNS itself can also be delivered directly in the RA, so home networks often do not need DHCPv6 at all. DNS from the course DNS and names in the network works on: for IPv6 the AAAA record takes the place of the A record. One name can have both, and the client picks.

One trap: under DHCPv6 a device is identified not by its MAC address but by a DUID identifier, so an old MAC-based reservation does not carry over automatically.

Step by step

  1. The note in the router’s RA message decides how to get an address.
  2. DHCPv6 can assign an address or merely add the details SLAAC does not provide.
  3. DNS works on. The AAAA record returns the IPv6 address and the A record the old one.

▶ Open in the simulator

Lesson 4: Living with IPv4

No NAT, but a firewall

PCSWRINTERNETPHONESERVERLAPTOPno NAT: the address stays the same along the way

When every device has a global address, NAT is not needed. That is good news: port forwarding goes away and applications can connect directly. A dangerous misconception appears, though. With IPv4 people got used to the inside network being “hidden”.

In reality that protection came mainly from the stateful firewall, and NAT contributed only as a side effect. Without NAT every device is addressable from outside, so the rule is clear: IPv6 needs a firewall just as IPv4 does. The default at the network edge is the same as in the course Network security: anyone may start a connection outward, inward only what you explicitly allow, and replies pass because the firewall remembers them.

Decent home routers work this way, but check yours. Also note that IPv4 and IPv6 rules are usually written separately, and setting up one does not mean you have the other.

Step by step

  1. Without NAT the PC goes out under its own address. There is nothing to translate.
  2. The PC can now be targeted directly from outside. What the firewall does about it is what counts.
  3. The stateful firewall on the router drops the unsolicited connection. Same as with IPv4.
  4. IPv4 and IPv6 rules are usually separate. Setting up one does not give you the other.

Dual stack

PCSWRINTERNETPHONESERVERLAPTOPPC: 192.168.1.10 and 2001:db8::10 at once

IPv4 and IPv6 do not talk to each other directly: they are two different protocols, and a server that knows only IPv4 does not understand an IPv6 address. The world cannot switch overnight, so the most common approach is dual stack: devices and the network run both protocols at the same time.

A computer has both an IPv4 and an IPv6 address and decides the way based on the destination. When DNS is asked about a name, it returns both A and AAAA records and the client tries both paths. Today’s browsers and apps try IPv6 first, and if it does not succeed within a fraction of a second, they add IPv4.

They use whichever path connects first; this is called Happy Eyeballs. Thanks to that, a user usually does not even notice an IPv6 outage. There are two sides to this. A broken IPv6 can stay hidden for a long time, because traffic moves to IPv4 by itself.

And above all, in dual stack everything is done twice: the address plan, firewall rules, monitoring and logs. Whatever you forget on one side is a hole.

Step by step

  1. In dual stack a device has both addresses and the two protocols run side by side.
  2. DNS returns both addresses. The client now knows two paths to the same server.
  3. Happy Eyeballs: it tries IPv6 first, adds IPv4 after a short delay and uses whichever path connects first.
  4. The price is that you do everything twice. What you forget on one side is a hole.

Tunnels and NAT64

PCSWRINTERNETPHONESERVERLAPTOPtunnel: IPv6 inside IPv4

Dual stack needs an IPv4 address for everyone, and those are expensive. That is why methods exist for cases where one side knows only one protocol. A tunnel wraps an IPv6 packet in IPv4 and carries it across a stretch that does not speak IPv6, much like a VPN, but without encryption.

It works, but a firewall that does not look inside the tunnel will not see the content. NAT64 solves the opposite situation: the network runs on IPv6 only and a client wants to reach a server that knows only IPv4. A gateway between them translates, helped by DNS64, which makes up a substitute IPv6 address for the IPv4 server.

The client believes it is speaking IPv6 and the gateway translates. Many mobile networks run this way today, and your phone may too. One practical point follows for security. Older automatic tunnels, such as 6to4 or Teredo, have no place in a modern network and should be blocked, as they could carry traffic past your rules.

Step by step

  1. A tunnel wraps IPv6 in IPv4 and carries it across a stretch that does not speak IPv6.
  2. A phone on an IPv6-only network asks about a server with no AAAA. DNS64 makes up a substitute address.
  3. NAT64 at the edge translates IPv6 to IPv4. The client knows nothing about it.
  4. Old automatic tunnels (6to4, Teredo) would carry traffic past your rules. Block them.

▶ Open in the simulator

Lesson 5: IPv6 security

You cannot simply ban ICMPv6

PCSWRINTERNETPHONESERVERLAPTOPlarge packet: 1500 bytes

In IPv4 a security team sometimes bans ICMP entirely and the network somehow survives. With IPv6 that does not work. ICMPv6 is not just ping. NDP runs over it, meaning the discovery of neighbors and routers, so with a full ban the local network stops working.

And there is a second thing: IPv6 routers do not split (fragment) packets. When a packet is too big for the next stretch, the router drops it and sends the sender a Packet Too Big message asking for smaller ones. If a firewall blocks that message, a nasty fault appears: the connection comes up, small packets pass, but a large transfer stalls.

A page starts loading and never finishes. The IPv6 header is simpler, by the way: it has a fixed length and a Hop Limit field in place of TTL. The right approach is to allow the required ICMPv6 types, mainly Packet Too Big and NDP, and to filter what is not needed.

Step by step

  1. The server sends a large packet. The next stretch past the router cannot carry packets that big.
  2. An IPv6 router does not split the packet. It drops it and must let the sender know.
  3. The Packet Too Big message tells the server to send smaller. The transfer goes on.
  4. When a firewall bans ICMPv6, the message never arrives. Small packets pass, a large transfer stalls.

The rogue router

PCSWRINTERNETPHONESERVERATTACKERcorrect: the gateway is router R

Remember the rogue DHCP server from the course DHCP: how a device gets an address? IPv6 has the same problem in a more painful form. Devices trust every Router Advertisement they see on the local network, because NDP verifies nothing. It is enough for an attacker’s laptop to send one, and the neighbors set it as their default gateway.

All IPv6 traffic then flows through it, which is a classic on-path attack. It can happen by accident too, when someone plugs in a misconfigured router. The worst part is that the attack works even on a network where you “do not use” IPv6: most systems have it switched on and prefer it.

Combined with forged DNS, the attacker also pulls in connections that would otherwise use IPv4. The defense sits on the switch and is called RA Guard: RA messages are allowed only from the port with the real router and dropped from all others. DHCPv6 Guard does the same job for DHCPv6. It is the same idea as DHCP snooping.

Step by step

  1. The normal state: the PC sends traffic out through the real router.
  2. The attacker sends a rogue RA. Nobody verifies it, so the neighbors believe it.
  3. The PC now sends its IPv6 traffic through the attacker, who can read and change it.
  4. RA Guard on the switch allows RA only from the router’s port and drops it from all others.

The IPv6 you do not know about

PCSWRINTERNETPHONESERVERLAPTOPIPv6 runs even if you do not know it

The biggest IPv6 risk is not in the protocol. It is that nobody is watching it. In a company IPv6 can be running on every laptop while monitoring, rules and logs count only on IPv4. Such traffic then passes unseen. Yet simple steps exist: find out what actually runs on the network, put IPv6 into the same rules and logs as IPv4, and verify that your tools can process the addresses.

If you truly do not use IPv6, turn it off or block it in a controlled way, but beware: some systems count on it and switching it off blindly can break things. Network reconnaissance changes too. Walking a /64 address by address is unrealistic, so an attacker on a network looks differently: reading DNS and logs, or asking the ff02::1 group on the spot.

Predictable addresses such as ::1 or ::10 are still an easy target. The large address space does not protect you from attack; it is only a small bonus.

Step by step

  1. Most devices have IPv6 switched on. The company often does not know.
  2. When monitoring and rules see only IPv4, IPv6 traffic passes unseen.
  3. Walking a /64 address by address is impossible. So an attacker searches via DNS, logs and multicast.
  4. The fix is ordinary: IPv6 belongs in the same rules, logs and tools as IPv4.

▶ Open in the simulator