---
title: "IPv6: Addressing, Autoconfiguration and Coexistence"
domain: networking
level: intermediate
duration: "60 min"
objectives:
  - "Explain why IPv6 exists and how it differs from IPv4: header format, extension headers, no broadcast, and end-to-end addressing without NAT."
  - "Read and write IPv6 addresses following RFC 5952, and identify address types and scopes: global unicast, unique local (ULA), link-local, multicast, anycast, loopback (`::1`) and unspecified (`::`)."
  - "Explain how a host configures itself: Neighbor Discovery Protocol (NDP), Router Advertisements and their flags, Stateless Address Autoconfiguration (SLAAC), temporary (privacy) addresses and DHCPv6."
  - "Plan IPv6 subnetting for a site: a `/48` or `/56` per site and a `/64` per network segment."
  - "Compare coexistence strategies (dual stack, NAT64/DNS64) and assess IPv6-specific risks: rogue Router Advertisements, over-filtered ICMPv6 and firewall rules that only cover IPv4."
---

# IPv6: Addressing, Autoconfiguration and Coexistence

## Why this matters
Your company says it "doesn't use IPv6." Then a visiting consultant plugs a travel router into a meeting-room port. Within seconds, half the laptops on that floor have a new address and a new default route, and their traffic starts flowing through the consultant's box instead of the corporate firewall. Nobody configured anything. Every modern operating system has **Internet Protocol version 6 (IPv6)** turned on by default and believes the first router that announces itself.

The same week, the marketing team asks why some mobile customers reach the website over IPv6 when the website has no IPv6 address at all. Their carrier runs an IPv6-only network and translates to IPv4 at its edge. IPv6 is already on your network and in your customers' hands, whether or not you planned for it. This lesson gives you what you need to read its addresses, understand how hosts configure themselves, plan a site, and close the gaps that an "IPv4-only" mindset leaves open.

## Learning objectives
- Explain why IPv6 exists and how it differs from IPv4: header format, extension headers, no broadcast, and end-to-end addressing without NAT.
- Read and write IPv6 addresses following RFC 5952, and identify address types and scopes: global unicast, unique local (ULA), link-local, multicast, anycast, loopback (`::1`) and unspecified (`::`).
- Explain how a host configures itself: Neighbor Discovery Protocol (NDP), Router Advertisements and their flags, Stateless Address Autoconfiguration (SLAAC), temporary (privacy) addresses and DHCPv6.
- Plan IPv6 subnetting for a site: a `/48` or `/56` per site and a `/64` per network segment.
- Compare coexistence strategies (dual stack, NAT64/DNS64) and assess IPv6-specific risks: rogue Router Advertisements, over-filtered ICMPv6 and firewall rules that only cover IPv4.

## Key concepts

### Why IPv6, and what changed
IPv4 has 32-bit addresses: about 4.3 billion in total, and far fewer usable once you remove private, multicast and reserved ranges. The Internet Assigned Numbers Authority (IANA) handed out its last free IPv4 blocks to the Regional Internet Registries (RIRs) in February 2011, and the RIRs have since run out of ordinary allocations too. The industry stretched IPv4 with **network address translation (NAT)**: many private addresses (RFC 1918) share one public address. Carriers now stack a second layer, Carrier-Grade NAT (CGNAT, RFC 6598 shared space), on top of the home router's NAT.

NAT works, but it has side effects:
- **Hosts are no longer reachable end to end.** Inbound connections need port forwarding, and peer-to-peer applications (voice, gaming, video calls) need helpers to traverse NAT.
- **State in the middle.** The NAT box keeps a table of every flow. It can run out of ports, and when it reboots every connection breaks.
- **Logging gets harder.** To identify who did something, you need the public address, the port and an exact timestamp, and then the NAT logs.

IPv6 uses 128-bit addresses: 2¹²⁸, about 3.4 × 10³⁸. That's enough to give every network segment 2⁶⁴ addresses and every site tens of thousands of segments. NAT is no longer needed to save addresses, so every host can have a globally unique address again. Reachability is then decided by your firewall, not by an accident of address translation.

IPv6 (RFC 8200) is not just "IPv4 with longer addresses." The designers also cleaned up the header and moved several jobs around:

| | IPv4 | IPv6 |
|---|---|---|
| Address size | 32 bits | 128 bits |
| Header | 20–60 bytes; options inside the header | Fixed **40 bytes**; options moved to **extension headers** |
| Header checksum | Yes, recomputed at every hop | None (the link layer and the Transmission Control Protocol, TCP, and User Datagram Protocol, UDP, already check; the UDP checksum is mandatory in IPv6) |
| Fragmentation | By the sender or by any router | Only by the source host; routers never fragment |
| Minimum maximum transmission unit (MTU) every link must carry | 68 bytes (RFC 791) | 1280 bytes |
| Hop counter | Time to Live (TTL) | **Hop Limit** (same job, honest name) |
| Broadcast | Yes | **None**: replaced by multicast |
| Address resolution (IP → media access control, MAC, address) | Address Resolution Protocol (ARP) | Neighbor Discovery (NDP), carried in the Internet Control Message Protocol for IPv6 (ICMPv6) |
| Address configuration | Manual or Dynamic Host Configuration Protocol (DHCP) | SLAAC and/or DHCP for IPv6 (DHCPv6), or manual |
| EtherType on Ethernet | `0x0800` | `0x86DD` |
| Role of ICMP | Helpful, often filtered | **Essential**: NDP and path MTU discovery depend on it |

The fixed IPv6 header has only eight fields:

| Field | Bits | Purpose |
|---|---|---|
| Version | 4 | Always `6`. |
| Traffic Class | 8 | Quality of service marking (Differentiated Services Code Point, DSCP, and Explicit Congestion Notification, ECN), as in IPv4. |
| Flow Label | 20 | Lets the source tag packets of one flow, for example for load balancing. |
| Payload Length | 16 | Bytes after the 40-byte header, including extension headers. |
| Next Header | 8 | What comes next: an extension header or the upper-layer protocol (`6` TCP, `17` UDP, `58` ICMPv6). |
| Hop Limit | 8 | Decremented by each router; the packet is discarded at 0. |
| Source address | 128 | |
| Destination address | 128 | |

**Extension headers** sit between the fixed header and the payload, chained through the Next Header field. Common ones are Hop-by-Hop Options (`0`), Routing (`43`), Fragment (`44`), Encapsulating Security Payload (`50`), Authentication Header (`51`) and Destination Options (`60`). Routers along the path only need to look at the fixed header (and Hop-by-Hop Options, if present), which keeps forwarding simple.

Because routers never fragment, a router that receives a packet too big for the next link drops it and sends an ICMPv6 **Packet Too Big** message (type 2) back to the source. The source then lowers its packet size. This is **path MTU discovery (PMTUD)** (RFC 8201), and it only works if Packet Too Big messages get through. Remember that for the security section.

> [!CHECK]
> An IPv6 packet of 1500 bytes reaches a router whose next link has an MTU of 1400 bytes. What does the router do?
>
> - [ ] Splits the packet into two fragments and forwards both
> - [ ] Clears a "don't fragment" flag and forwards the packet anyway
> - [x] Drops the packet and sends an ICMPv6 Packet Too Big message to the source
>
> IPv6 routers never fragment. The source learns the smaller MTU from the Packet Too Big message and resends smaller packets; only the source may fragment, using the Fragment extension header.

### Writing IPv6 addresses
An IPv6 address is 128 bits written as eight groups of four hexadecimal digits, separated by colons. Each group is 16 bits. Written in full, an address is long:

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

The same address can be shortened in several ways, and different tools used to print it differently. That made logs hard to search and configurations hard to compare. **RFC 5952** fixes one canonical text form. Apply its rules in this order:

1. **Use lowercase** hexadecimal digits: `2001:DB8::1` becomes `2001:db8::1`.
2. **Drop leading zeros** in every group: `0db8` becomes `db8`, `0042` becomes `42`, `0000` becomes `0`.
3. **Replace the longest run of consecutive all-zero groups with `::`**, but only if the run is at least two groups long.
4. **If two runs tie** for longest, compress the **leftmost** one.
5. **Never use `::` for a single zero group**, and never use `::` more than once (the reader couldn't tell how many zeros each one hides).

| Full form | RFC 5952 form | Rule shown |
|---|---|---|
| `2001:0db8:0000:0000:0000:ff00:0042:8329` | `2001:db8::ff00:42:8329` | Leading zeros dropped; three zero groups become `::` |
| `2001:0db8:0000:0000:0001:0000:0000:0001` | `2001:db8::1:0:0:1` | Two runs of two: the leftmost is compressed |
| `2001:0db8:0000:0000:0001:0000:0000:0000` | `2001:db8:0:0:1::` | Runs of two and three: the longest wins, even on the right |
| `2001:0db8:0000:0001:0001:0001:0001:0001` | `2001:db8:0:1:1:1:1:1` | A single zero group stays `0` |
| `0000:0000:0000:0000:0000:0000:0000:0001` | `::1` | The loopback address |
| `0000:0000:0000:0000:0000:0000:0000:0000` | `::` | The unspecified address |

To **expand** an address, do the reverse: pad every group to four digits, then fill `::` with as many `0000` groups as needed to reach eight.

Prefixes use the same CIDR (Classless Inter-Domain Routing) notation as IPv4: `2001:db8:acad::/48` means "the first 48 bits are fixed." Because a colon also separates host and port, URLs and `host:port` strings put the address in square brackets: `https://[2001:db8::10]:8443/`.

> [!NOTE]
> All global examples in this module use `2001:db8::/32`, the prefix reserved for documentation by RFC 3849. It is never routed on the Internet.

> [!CHECK]
> What is the RFC 5952 form of `2001:0db8:0000:0042:0000:0000:0000:0001`?
>
> - [ ] `2001:db8::42::1`
> - [ ] `2001:db8::42:0:0:0:1`
> - [x] `2001:db8:0:42::1`
> - [ ] `2001:DB8:0:42::1`
>
> The run of three zero groups after `42` is the longest, so it becomes `::`. The single zero group after `db8` stays `0`. Two `::` would be ambiguous, and RFC 5952 requires lowercase.

### Address types and scopes
IPv6 has no broadcast. It has three kinds of address: **unicast** (one interface), **multicast** (every interface that joined a group) and **anycast** (the nearest of several interfaces that share one unicast address). Each address also has a **scope**: the part of the network where it is valid and unique.

| Type | Prefix | Scope | Example | Notes |
|---|---|---|---|---|
| **Global unicast address (GUA)** | `2000::/3` | Global | `2001:db8:acad:10::1` | Routable on the Internet; the IPv6 equivalent of a public IPv4 address. |
| **Unique local address (ULA)** | `fc00::/7` (in practice `fd00::/8`) | Global scope, but routed only inside a site or between sites that agree | `fd8f:3c2a:61e4:10::1` | Like RFC 1918, but each site picks a random 40-bit global ID (RFC 4193), so merging two networks rarely clashes. |
| **Link-local** | `fe80::/10` (hosts use `fe80::/64`) | One link | `fe80::200:5eff:fe00:5310` | Every IPv6 interface has one, always. Never forwarded by routers. |
| **Multicast** | `ff00::/8` | Set by the scope field | `ff02::1` | Replaces broadcast. See below. |
| Anycast | (taken from unicast space) | As the unicast prefix | `2001:db8:acad:10::` | Looks like unicast; several interfaces share it and routing delivers to the nearest. |
| **Loopback** | `::1/128` | The host itself | `::1` | Like `127.0.0.1`. |
| **Unspecified** | `::/128` | None | `::` | "No address yet": the source address of a host that hasn't got one. |
| IPv4-mapped | `::ffff:0:0/96` | The host itself | `::ffff:192.0.2.10` | How a dual-stack socket API represents an IPv4 peer. Not sent on the wire. |

A few points deserve detail:

- **Global unicast structure.** A GUA is normally split into a global routing prefix (from your Internet service provider, ISP, or RIR), a subnet ID (you choose it) and a 64-bit **interface ID** (IID) that identifies the interface on its segment. Figure 1 shows the split.
- **ULA global ID.** `fd` is followed by a 40-bit global ID that you generate randomly, for example `fd8f:3c2a:61e4::/48`. Don't pick `fd00::/48` or other easy-to-guess values: random IDs are what keep two companies' ULAs from overlapping after a merger. The `fc00::/8` half is reserved and not used.
- **Multicast scope.** In `ff0X::`, the fourth hex digit is the scope: `1` interface-local, `2` link-local, `5` site-local, `8` organization-local, `e` global. Well-known link-local groups include `ff02::1` (all nodes), `ff02::2` (all routers) and `ff02::1:2` (all DHCPv6 servers and relay agents).
- **Solicited-node multicast.** For each unicast address it has, a host joins `ff02::1:ff` followed by the address's **last 24 bits**. `2001:db8:acad:10:4c3e:9b12:a7f0:6d21` → `ff02::1:fff0:6d21`. Neighbor Discovery sends its questions to this group, so only the few hosts whose addresses end the same way are disturbed. Compare that with an ARP broadcast, which interrupts every host on the segment.

![An IPv6 global unicast address split into a 48-bit global routing prefix, a 16-bit subnet ID and a 64-bit interface ID, with the /48 site prefix and the /64 network prefix marked](../../../assets/diagrams/ipv6-gua-structure.svg)

*Figure 1. Structure of a global unicast address. The site gets the /48; you choose a subnet ID per segment; the host's interface ID fills the last 64 bits.*

**A host has several addresses at once.** A typical laptop interface holds a link-local address, a stable global address, one or more temporary global addresses (see autoconfiguration below), perhaps a ULA, plus `::1` on the loopback interface. It also listens on several multicast groups. This is normal, not a misconfiguration.

**Link-local addresses need a zone ID.** Every interface has an address in `fe80::/64`, so `fe80::1` alone is ambiguous on a machine with Wi-Fi and Ethernet: which link? You add a **zone ID** (RFC 4007) after a `%`: `fe80::1%eth0` on Linux, `fe80::1%en0` on macOS, or a numeric interface index such as `fe80::1%12` on Windows.

> [!CHECK]
> A host's interface shows the addresses `fe80::4c3e:9b12:a7f0:6d21`, `2001:db8:acad:10:4c3e:9b12:a7f0:6d21` and `fd8f:3c2a:61e4:10::25`. Which one can a server on the Internet reach directly?
>
> - [ ] `fe80::4c3e:9b12:a7f0:6d21`, because it is unique to this interface
> - [x] `2001:db8:acad:10:4c3e:9b12:a7f0:6d21`, the global unicast address
> - [ ] `fd8f:3c2a:61e4:10::25`, because ULAs have global scope
> - [ ] None of them: IPv6 hosts are only reachable through NAT
>
> Only the address from `2000::/3` is routed on the Internet (in real life, of course, not from the documentation prefix). Link-local addresses never leave the link, and ULAs are routed only inside the site even though they are globally unique.

### Neighbor Discovery and autoconfiguration
**Neighbor Discovery Protocol (NDP)** (RFC 4861) is a set of ICMPv6 messages that hosts and routers use on a link. It replaces ARP, ICMP router discovery and ICMP redirects from IPv4. Five message types do the work:

| ICMPv6 type | Message | Sent by → to | Purpose |
|---|---|---|---|
| 133 | **Router Solicitation (RS)** | Host → `ff02::2` | "Any routers here? Please advertise now." |
| 134 | **Router Advertisement (RA)** | Router → `ff02::1` (periodically, or in reply to an RS) | Announces the router, the prefixes on the link, flags, MTU and often Domain Name System (DNS) servers. |
| 135 | **Neighbor Solicitation (NS)** | Node → solicited-node group (or unicast) | "Who has this address? What's your link-layer (MAC) address?" Also used for duplicate address detection and reachability checks. |
| 136 | **Neighbor Advertisement (NA)** | Node → the asker (or `ff02::1`) | "That address is mine; here is my MAC address." |
| 137 | **Redirect** | Router → host | "For that destination, use a better next hop on this link." |

NDP messages are sent with Hop Limit 255, and receivers discard any that arrive with a lower value. A packet from another network would have crossed a router and lost at least one hop, so this check stops off-link spoofing. It does nothing against an attacker on the same link (see Security considerations).

Each host keeps a **neighbor cache**, the IPv6 version of the ARP table. Entries move through states such as `INCOMPLETE` (asked, no answer yet), `REACHABLE` (confirmed recently), `STALE` (not confirmed lately; checked again on next use), `DELAY` and `PROBE`.

**Router Advertisements drive autoconfiguration.** An RA carries:
- a **router lifetime**: if it is non-zero, hosts use this router as a default gateway. The default route always comes from RAs, never from DHCPv6.
- one or more **Prefix Information Options (PIOs)**, each with a prefix (normally a `/64`), valid and preferred lifetimes, and flags: **L** (on-link: hosts on this prefix are reachable directly) and **A** (autonomous: hosts may build their own address from this prefix with SLAAC).
- two flags in the RA header: **M** (Managed: addresses are available from DHCPv6) and **O** (Other configuration: other settings, such as DNS servers, are available from DHCPv6).
- optional extras such as the link MTU and DNS servers in the Recursive DNS Server (RDNSS) option (RFC 8106).

| M | O | A (in the PIO) | What hosts typically do |
|---|---|---|---|
| 0 | 0 | 1 | SLAAC only. DNS servers come from the RDNSS option in the RA. |
| 0 | 1 | 1 | SLAAC for addresses; **stateless DHCPv6** for other settings (DNS, domain search list, Network Time Protocol (NTP) servers). |
| 1 | (any) | 0 | **Stateful DHCPv6** assigns addresses; no SLAAC. |
| 1 | (any) | 1 | Both: hosts may have a SLAAC address and a DHCPv6 address. |

> [!NOTE]
> M and O are hints, and operating systems interpret them differently. For example, Android does not implement stateful DHCPv6 address assignment, so an M=1, A=0 network leaves Android devices with only a link-local address. Test the combination you choose with the clients you actually have.

**Stateless Address Autoconfiguration (SLAAC)** (RFC 4862) lets a host build its own global address: prefix from the RA (64 bits) + an interface ID it generates (64 bits). No server keeps any state. How the host chooses the interface ID has changed over time:

| Method | How the interface ID is formed | Privacy |
|---|---|---|
| **Modified EUI-64** (64-bit Extended Unique Identifier; RFC 4291, Appendix A) | From the 48-bit MAC address: insert `ff:fe` in the middle and flip the universal/local bit. MAC `00:00:5e:00:53:10` → IID `200:5eff:fe00:5310`. | Poor: the same IID on every network reveals the MAC address and lets anyone track the device across networks. RFC 8064 recommends against it. |
| **Stable privacy** (RFC 7217) | A hash of the prefix, the interface, a secret key and other inputs. | Good: stable on one network (useful for servers, logs, firewall rules), different on every other network. |
| **Temporary addresses** (RFC 8981) | Random, regenerated regularly (typically about once a day). Used as the source of outgoing connections. | Best for clients: remote servers can't link today's connections to tomorrow's. |

A typical client has a stable-privacy address (for incoming connections and management) **and** a temporary address (for outgoing connections). The old temporary address stays valid for a while after a new one appears, so existing connections don't break.

**DHCPv6** (RFC 8415) is the stateful alternative. Clients send to `ff02::1:2` from UDP port 546 to port 547 and are identified by a DHCP Unique Identifier (DUID), not by their MAC address. DHCPv6 is useful when you need a central record of which device has which address, or to hand out options that RAs can't carry. Two differences from IPv4 DHCP catch people out:
- **DHCPv6 does not provide a default gateway.** There is no "router" option. Hosts learn the default route only from RAs, so a DHCPv6-only network still needs RAs.
- **DHCPv6 does not tell the host the prefix length** of an assigned address. Hosts typically install it as a `/128` and learn the on-link `/64` from the RA's L flag.

DHCPv6 also has a router-to-router job, **prefix delegation (DHCPv6-PD)**: your ISP's equipment delegates a `/56` or `/48` to your edge router, which then carves `/64`s for its LANs.

> [!CHECK]
> A network uses stateful DHCPv6 for addresses (M=1, A=0). Hosts get an address, but cannot reach anything outside their subnet. What is the most likely cause?
>
> - [ ] The DHCPv6 server didn't send the default gateway option
> - [x] No router is sending Router Advertisements with a non-zero router lifetime
> - [ ] The hosts need temporary addresses before they can route
> - [ ] The DHCPv6 lease time is too long
>
> DHCPv6 has no default-gateway option. Hosts learn their default router only from RAs, so a DHCPv6 network still needs routers to advertise themselves.

### Planning IPv6 subnets
IPv4 subnetting is about conserving scarce addresses: you size each subnet to its host count with VLSM (Variable-Length Subnet Masking). IPv6 planning turns that around. Addresses are plentiful; what you optimize for is **simplicity, consistency and summarization**.

Two numbers cover almost every design:
- **Per site: a `/48` or a `/56`.** RFC 6177 says end sites should get enough space for multiple subnets, and the RIPE community's guidance (RIPE-690) recommends a `/48` for businesses and a `/56` for home users. A `/48` holds 2¹⁶ = 65,536 `/64` subnets; a `/56` holds 2⁸ = 256.
- **Per network segment: a `/64`.** Every LAN, VLAN (virtual LAN) and Wi-Fi network gets exactly a `/64`, whether it has three hosts or three thousand.

Why always `/64`? SLAAC builds an address from the prefix plus a 64-bit interface ID, and a host ignores a PIO whose prefix length plus 64 doesn't equal 128 (RFC 4862). Make a LAN a `/80` and SLAAC silently stops working there; Android clients, which rely on SLAAC, get no global address. RFC 7421 lists other things that assume the 64-bit boundary. Point-to-point links between routers are the common exception: RFC 6164 allows `/127` there, and many designs still reserve a whole `/64` per link and use a `/127` inside it.

Practical habits:
- **Plan on nibble boundaries.** One hexadecimal digit is 4 bits (a nibble), so `/48`, `/52`, `/56`, `/60` and `/64` line up with whole digits. A `/52` boundary changes one digit of the subnet ID; a `/50` would split a digit and make addresses hard to read.
- **Make the subnet ID meaningful.** For example, the first digit is the building and the last three are the VLAN number: VLAN 10 in building 0 → subnet ID `0010`. Keep in mind it is still hexadecimal: `0010` is 16 in decimal, not 10.
- **Summarize per area.** Give each building or region a contiguous block (for example a `/52`) so it can be advertised as one route.
- **Don't renumber by hand.** Keep the prefix in one place in your configuration (variables, IP address management tools), because ISP-assigned prefixes can change.

> [!CHECK]
> A branch office receives `2001:db8:acad::/56` from its ISP and has 40 VLANs, one of which has only 4 hosts. What prefix length should the 4-host VLAN get?
>
> - [ ] `/125`, because 8 addresses are enough for 4 hosts
> - [ ] `/120`, to leave room for growth while saving space
> - [x] `/64`, like every other segment
> - [ ] `/56`, the whole site prefix
>
> Every segment gets a `/64` so SLAAC works and the plan stays uniform. A `/56` holds 256 `/64`s, plenty for 40 VLANs; there is nothing to gain by shrinking a LAN prefix.

### Coexistence with IPv4
The Internet won't switch overnight, so networks run both protocols for years. Three families of techniques make that work:

- **Dual stack.** Every host and router runs IPv4 and IPv6 side by side. DNS returns both A (IPv4) and AAAA (IPv6) records (RFC 3596). Clients prefer IPv6 by default (RFC 6724) and use **Happy Eyeballs** (RFC 8305) to try both quickly, so a broken IPv6 path doesn't make users wait. Dual stack is the simplest and most common approach, but you operate, secure and monitor two networks.
- **Translation: NAT64 and DNS64.** The network is IPv6-only, and a gateway translates to IPv4 for destinations that have no IPv6. **DNS64** (RFC 6147) answers AAAA queries for IPv4-only names by synthesizing an address that embeds the IPv4 address in a prefix, usually the well-known prefix **`64:ff9b::/96`** (RFC 6052). **NAT64** (RFC 6146) is the stateful translator that receives packets for that prefix and sends them to the IPv4 Internet. Mobile carriers use this widely, often with 464XLAT (RFC 6877), which adds a small translator on the device so applications that use IPv4 literals still work.
- **Tunnels.** IPv6 packets carried inside IPv4 (6in4, IP protocol number 41), or the other way round. They were common in the early days and are mostly a stopgap now; the automatic 6to4 mechanism is deprecated (RFC 7526).

![NAT64 and DNS64: an IPv6-only client asks DNS64 for www.example.com, receives the synthesized address 64:ff9b::cb00:7150, sends IPv6 to the NAT64 gateway, which talks IPv4 to the server 203.0.113.80 and translates the reply back](../../../assets/diagrams/ipv6-nat64-dns64.svg)

*Figure 2. NAT64 and DNS64. `cb00:7150` is `203.0.113.80` written in hexadecimal (`cb`=203, `00`=0, `71`=113, `50`=80).*

> [!NOTE]
> RFC 6052 says the well-known prefix `64:ff9b::/96` must not be used to represent private (RFC 1918) IPv4 addresses. An operator who needs that uses its own network-specific prefix instead.

> [!CHECK]
> On an IPv6-only network with NAT64/DNS64, an application connects to a hard-coded IPv4 literal, `203.0.113.80`, instead of a name. Why does this fail?
>
> - [ ] NAT64 only translates TCP, not UDP
> - [x] No DNS lookup happens, so DNS64 never synthesizes an IPv6 address for the client to use
> - [ ] `203.0.113.80` cannot be embedded in `64:ff9b::/96`
> - [ ] Happy Eyeballs blocks IPv4 literals
>
> DNS64 only helps when the client asks DNS. An IPv4 literal skips that step, and an IPv6-only host has no IPv4 route. 464XLAT exists to fix exactly this case.

## How it works
Follow a laptop that connects to VLAN 10 in building 0 of the site `2001:db8:acad::/48`. The router is configured with the link-local address `fe80::1` and advertises `2001:db8:acad:10::/64`, with A=1, L=1, M=0, O=0, and a DNS server in the RDNSS option.

![A laptop joins an IPv6 link: tentative link-local address, duplicate address detection, Router Solicitation, Router Advertisement with prefix 2001:db8:acad:10::/64, stable and temporary global addresses, default route via fe80::1, and neighbor resolution of the router](../../../assets/diagrams/ipv6-slaac.svg)

*Figure 3. A laptop joins the network. Green boxes are what the laptop does on its own; arrows are the ICMPv6 messages it exchanges. The numbers match the steps below.*

1. **Link-local address.** As soon as the link comes up, the laptop generates an interface ID and forms `fe80::<IID>`. The address is **tentative**: it can't be used yet. The laptop also joins `ff02::1` and the solicited-node group of the tentative address, announcing that with Multicast Listener Discovery (MLD) reports so that switches doing MLD snooping forward the right multicast to it.
2. **Duplicate address detection (DAD).** The laptop sends an NS whose target is its tentative address, from the unspecified source `::` (it has no address it may use yet), to that address's solicited-node group. If another node answers with an NA, the address is a duplicate and the laptop doesn't use it. If nothing comes back within about a second, the address becomes usable.
3. **Router Solicitation.** Instead of waiting for the next periodic RA, the laptop sends an RS to `ff02::2`.
4. **Router Advertisement.** The router replies with an RA to `ff02::1` carrying the prefix, flags, router lifetime and DNS server.
5. **Global addresses.** A=1 and a `/64` prefix: the laptop builds a stable-privacy address (for example `2001:db8:acad:10:4c3e:9b12:a7f0:6d21`) and a temporary address. M=0 and O=0, so it doesn't contact DHCPv6; DNS comes from the RDNSS option.
6. **DAD again**, for each new address.
7. **Default route.** Because the router lifetime is non-zero, the laptop installs a default route via the router's **link-local** address `fe80::1`. Routers are always addressed by their link-local address as a next hop; it stays the same even if the global prefix changes.
8. **Address resolution.** To send its first packet off the link, the laptop needs the router's MAC address. It sends an NS to the solicited-node group of `fe80::1`, which is `ff02::1:ff00:1`. The router answers with an NA, and the neighbor cache entry becomes `REACHABLE`.

On Linux, `ip -6 route` then shows a line like `default via fe80::1 dev eth0 proto ra`; `proto ra` tells you the route was learned from a Router Advertisement.

> [!CHECK]
> In step 2, why does the laptop send its duplicate address detection NS from `::` instead of from the address it is testing?
>
> - [ ] `::` is the all-routers address, so the router answers faster
> - [x] The tested address is still tentative and may belong to someone else, so the laptop must not use it as a source yet
> - [ ] NDP messages always use `::` as their source address
> - [ ] Using `::` makes the message cross routers to check the whole site
>
> A tentative address isn't the laptop's until DAD succeeds. Sending from `::` avoids polluting other nodes' neighbor caches with a possibly duplicate address. Later NDP messages, such as the NS in step 8, use a real source address.

## Worked example
Example Corp gets `2001:db8:acad::/48` from its ISP for its headquarters (building 0) and a warehouse (building 1). It also generates a ULA prefix for internal-only services: a random 40-bit global ID gives `fd8f:3c2a:61e4::/48`.

**The plan.** The subnet ID is the 16 bits after the `/48`, written as four hex digits. Example Corp uses the first digit for the building and writes the VLAN number in the last three digits, so humans can read it at a glance:

| Building | VLAN | Purpose | Subnet ID | GUA prefix | ULA prefix |
|---|---|---|---|---|---|
| 0 (HQ) | 10 | Staff | `0010` | `2001:db8:acad:10::/64` | `fd8f:3c2a:61e4:10::/64` |
| 0 (HQ) | 20 | Guest Wi-Fi | `0020` | `2001:db8:acad:20::/64` | (none: guests don't need internal services) |
| 0 (HQ) | 100 | Servers | `0100` | `2001:db8:acad:100::/64` | `fd8f:3c2a:61e4:100::/64` |
| 1 (warehouse) | 10 | Staff | `1010` | `2001:db8:acad:1010::/64` | `fd8f:3c2a:61e4:1010::/64` |
| f (infrastructure) | — | Router loopbacks | `f000` | `2001:db8:acad:f000::/64` (one `/128` per router) | — |

Each building owns a `/52`: HQ is `2001:db8:acad::/52` (subnet IDs `0000`–`0fff`, 4,096 `/64`s) and the warehouse is `2001:db8:acad:1000::/52` (`1000`–`1fff`). The warehouse router can advertise its whole building as a single `/52` route.

> [!NOTE]
> Writing the VLAN number in hex digits wastes some of the space (`0010` is really subnet 16), and VLAN numbers above 999 don't fit. That's an acceptable trade-off for readability with 4,096 subnets per building; larger organizations choose other schemes.

**One host.** A laptop on HQ staff VLAN 10 ends up with:

| Address | Type | How it got it |
|---|---|---|
| `fe80::4c3e:9b12:a7f0:6d21` | Link-local | Generated at link up |
| `2001:db8:acad:10:4c3e:9b12:a7f0:6d21` | GUA, stable | SLAAC (stable privacy IID) |
| `2001:db8:acad:10:91d4:2e6b:c07a:3f58` | GUA, temporary | SLAAC (RFC 8981), source of outgoing connections |
| `fd8f:3c2a:61e4:10:4c3e:9b12:a7f0:6d21` | ULA | SLAAC from a second PIO in the same RA |

> [!NOTE]
> For simplicity this example reuses one interface ID across prefixes. With RFC 7217 stable privacy addresses, the IID is derived from the prefix too, so a real host would normally show a different IID for each prefix.

Derived values for the stable GUA:
- **Solicited-node group:** last 24 bits `f0:6d21` → `ff02::1:fff0:6d21`.
- **Ethernet multicast MAC** for that group: `33:33` followed by the last 32 bits of the group address (RFC 2464) → `33:33:ff:f0:6d:21`. Switches deliver this frame only to ports whose hosts joined the group (with MLD snooping).
- **Default gateway:** `fe80::1%eth0`, learned from the RA.
- **Reaching an IPv4-only site through NAT64:** `203.0.113.80` → `64:ff9b::cb00:7150`.

## Common pitfalls
- **Leaving out the zone ID.** `ping fe80::1` fails or picks the wrong interface on a multi-homed host. Use `fe80::1%eth0` (or `%<index>` on Windows).
- **Compressing a single zero group, or using `::` twice.** `2001:db8::1:1:1:1:1` is valid input, but the canonical form is `2001:db8:0:1:1:1:1:1`. `2001::1::2` is invalid.
- **Making LANs smaller than `/64`.** It saves nothing and breaks SLAAC. Use `/64` per segment; reserve `/127` for router-to-router links.
- **Reading subnet IDs as decimal.** `2001:db8:acad:10::/64` is subnet 16, and the next one after `...:19::` is `...:1a::`, not `...:20::`.
- **Expecting DHCPv6 to set the gateway.** It doesn't. Without RAs there is no default route.
- **Blocking all ICMPv6 "for security".** NDP stops working on the link, and Packet Too Big messages get dropped, which causes connections that open fine but hang on large transfers.
- **Configuring the firewall for IPv4 only.** Hosts are reachable over IPv6 even if nobody planned it. See below.
- **Comparing addresses as text.** `2001:DB8:0::1` and `2001:db8::1` are the same address. Normalize to RFC 5952 form before searching logs or comparing configurations.

## Security considerations
IPv6 is not more or less secure than IPv4 by nature. The risks come from assumptions: that IPv6 isn't there, that NAT was protecting you, or that IPv4 rules carry over automatically.

| Risk | Why it happens | Defenses |
|---|---|---|
| **IPv6 is on in an "IPv4-only" network** | Every current operating system enables IPv6 and link-local addresses by default and accepts RAs. | Treat IPv6 as present: monitor RAs and NDP, apply first-hop protections, decide on a policy deliberately. Think twice before disabling IPv6 on hosts: Microsoft, for example, advises against it on Windows because some components expect it. |
| **Rogue Router Advertisements** | Any host on the link can send RAs. A misconfigured device (a home router, a shared-connection laptop) or an attacker becomes the default gateway or hands out a bogus prefix or DNS server: a man-in-the-middle position. | **RA Guard** (RFC 6105) on switches: only ports facing real routers may send RAs. Keep switch software current: RFC 7113 describes evasions using extension headers and fixes for them. Also consider DHCPv6 Guard. |
| **NDP spoofing** | Like ARP spoofing: forged NAs redirect traffic for another address. The Hop Limit 255 check only stops off-link attackers. | Switch first-hop security features (ND inspection, source guard), segmenting untrusted users, monitoring. |
| **Over-filtered ICMPv6** | Rules copied from IPv4 "drop all ICMP." | Follow RFC 4890: always allow Packet Too Big (type 2), Destination Unreachable (1), Time Exceeded (3) and Parameter Problem (4), and NDP (133–137) on the link. Echo (128/129) can be allowed or rate-limited by policy. |
| **Firewall gaps** | Separate IPv4 and IPv6 rule sets (for example `iptables` and `ip6tables`; IPv4 and IPv6 rules in a cloud security group). Rules exist only for IPv4, so IPv6 is wide open, or blocked in a way that breaks things. | **Policy parity**: every rule exists for both families (or use tools that cover both, such as an nftables `inet` table). Default-deny inbound on a stateful firewall gives the "no unsolicited inbound" behaviour that people credited to NAT. |
| **Tunnels bypassing controls** | 6in4 and similar tunnels carry IPv6 inside IPv4 past filters that only look at IPv4. | Block IP protocol 41 and unknown tunnels at the perimeter unless you use them deliberately. |
| **Tracking and privacy** | EUI-64 IIDs embed the MAC address and stay the same everywhere. | Stable privacy (RFC 7217) and temporary (RFC 8981) addresses. Note the flip side for defenders: logs must record full addresses and keep NDP or DHCPv6 records long enough to map a temporary address back to a device. |

Scanning a `/64` address by address is infeasible (2⁶⁴ addresses), but don't rely on that. Attackers guess predictable addresses (`::1`, `::10`, EUI-64 patterns), harvest addresses from DNS and logs, and once on a link, simply ping `ff02::1` (RFC 7707 describes these techniques). Use random or stable-privacy IIDs for clients and rely on filtering, not obscurity, for servers.

> [!IMPORTANT]
> Only send NDP, multicast or scan traffic on networks you own or are explicitly authorized to test. The lab in this module is read-only and runs on your own machine and your own link.

## Summary
- IPv6 exists because IPv4 ran out; it brings 128-bit addresses, end-to-end addressing without NAT, a fixed 40-byte header with extension headers, no router fragmentation (Packet Too Big + PMTUD) and no broadcast.
- Write addresses in RFC 5952 form: lowercase, no leading zeros, `::` for the longest run of two or more zero groups (leftmost on a tie), never for a single group.
- Know the main prefixes: `2000::/3` global unicast, `fd00::/8` ULA, `fe80::/10` link-local (with a zone ID), `ff00::/8` multicast (`ff02::1`, `ff02::2`, solicited-node `ff02::1:ffXX:XXXX`), `::1` loopback, `::` unspecified. A host has several addresses at once.
- NDP (ICMPv6 types 133–137) replaces ARP and router discovery. RAs give the default route and prefixes; the A flag enables SLAAC, M and O point to DHCPv6. DHCPv6 never provides the default route.
- Interface IDs moved from MAC-based EUI-64 to stable privacy (RFC 7217) and temporary (RFC 8981) addresses.
- Plan a `/48` or `/56` per site and a `/64` per segment, on nibble boundaries, with meaningful subnet IDs.
- Coexist with dual stack or IPv6-only plus NAT64/DNS64 (`64:ff9b::/96`). Secure IPv6 even if you "don't use it": RA Guard, RFC 4890 ICMPv6 filtering and firewall parity.

## Glossary
| Term | Definition |
|---|---|
| Internet Protocol version 6 (IPv6) | The version of IP with 128-bit addresses, defined in RFC 8200. |
| Network address translation (NAT) | Rewriting IP addresses (and usually ports) in transit, typically so many private addresses share one public address. |
| Extension header | An optional IPv6 header between the fixed header and the payload, chained through the Next Header field (for example Fragment or Routing). |
| Hop Limit | The IPv6 header field that each router decrements; the packet is discarded when it reaches zero. IPv4 calls it TTL. |
| Packet Too Big | ICMPv6 type 2 message a router sends when a packet exceeds the next link's MTU. |
| Path MTU discovery (PMTUD) | The process by which a source learns the smallest MTU on the path from Packet Too Big messages (RFC 8201). |
| RFC 5952 | The recommendation that defines the canonical text form of IPv6 addresses. |
| Unicast / multicast / anycast | One interface / every interface that joined a group / the nearest of several interfaces sharing one address. |
| Scope | Where an address is valid and unique: one host, one link, a site, or the whole Internet. |
| Global unicast address (GUA) | A globally routable IPv6 address, from `2000::/3`. |
| Unique local address (ULA) | An address from `fd00::/8` with a random 40-bit global ID, routed only within a site or between cooperating sites (RFC 4193). |
| Link-local address | An address in `fe80::/10` valid only on one link; every IPv6 interface has one. |
| Multicast address | An address in `ff00::/8` that identifies a group of interfaces; the scope is encoded in the address. |
| Loopback address | `::1`, the host itself. |
| Unspecified address | `::`, meaning "no address"; used as a source before a host has an address. |
| Interface ID (IID) | The last 64 bits of a unicast address, identifying the interface on its link. |
| Solicited-node multicast address | `ff02::1:ff` plus the last 24 bits of a unicast address; the group NDP uses to resolve that address. |
| Zone ID | The `%<interface>` suffix that says which link a link-local address belongs to (RFC 4007). |
| Neighbor Discovery Protocol (NDP) | The ICMPv6-based protocol (RFC 4861) for router discovery, address resolution, DAD and redirects. |
| Router Solicitation (RS) | ICMPv6 type 133: a host asks routers to advertise. |
| Router Advertisement (RA) | ICMPv6 type 134: a router announces itself, prefixes, flags and options. |
| Neighbor Solicitation (NS) | ICMPv6 type 135: asks for a neighbor's link-layer address, or checks for duplicates or reachability. |
| Neighbor Advertisement (NA) | ICMPv6 type 136: answers an NS, or announces a change. |
| Redirect | ICMPv6 type 137: a router tells a host about a better next hop on the link. |
| Neighbor cache | A host's table of IPv6-to-link-layer address mappings and their reachability state; the IPv6 counterpart of the ARP table. |
| Router lifetime | The RA field saying how long hosts may use the router as a default gateway; zero means "not a default router." |
| Prefix Information Option (PIO) | The part of an RA that carries a prefix, its lifetimes and the L and A flags. |
| L flag / A flag | PIO flags: the prefix is on-link / hosts may autoconfigure addresses from it with SLAAC. |
| M flag / O flag | RA header flags: addresses are available via DHCPv6 / other configuration is available via DHCPv6. |
| Recursive DNS Server (RDNSS) option | An RA option that gives hosts DNS server addresses (RFC 8106). |
| Stateless Address Autoconfiguration (SLAAC) | Hosts build their own addresses from an RA prefix and an interface ID (RFC 4862). |
| Modified EUI-64 | An interface ID derived from the MAC address by inserting `ff:fe` and flipping the universal/local bit. |
| Stable privacy address | An address whose IID is a hash that stays the same on one network and differs between networks (RFC 7217). |
| Temporary address | A randomly generated, short-lived address used for outgoing connections (RFC 8981). |
| DHCPv6 | Dynamic Host Configuration Protocol for IPv6 (RFC 8415): stateful addresses, other options, and prefix delegation. |
| Prefix delegation (DHCPv6-PD) | A DHCPv6 mechanism through which a router receives a prefix (for example a `/56`) to subnet for its own networks. |
| Duplicate address detection (DAD) | Checking that an address is unused on the link before using it, with an NS sent from `::`. |
| Tentative address | An address that is still undergoing DAD and cannot be used yet. |
| Nibble boundary | A prefix length that is a multiple of 4 bits, so that it falls between hexadecimal digits. |
| Dual stack | Running IPv4 and IPv6 side by side on the same hosts and network. |
| Happy Eyeballs | A client algorithm that tries IPv6 and IPv4 connections in quick succession and uses whichever works first (RFC 8305). |
| DNS64 | A DNS resolver that synthesizes AAAA records for IPv4-only names (RFC 6147). |
| NAT64 | A stateful translator between IPv6 clients and IPv4 servers (RFC 6146). |
| RA Guard | A switch feature that blocks Router Advertisements on ports that shouldn't have routers (RFC 6105). |

## Check your understanding
1. A colleague says IPv6 is "safer because there's no NAT to forget about." What is right and wrong in that statement, and what actually controls inbound reachability on an IPv6 network?
2. Write `2001:0db8:0000:0000:0000:0000:0000:0000/32` and `fe80:0000:0000:0000:0000:0000:0000:0001` in RFC 5952 form. Why does the second one need a zone ID when you ping it?
3. A Linux host shows two global addresses in the same `/64`, one marked `temporary`. Which one would a web server on the Internet see in its logs when the host browses, and why does the host keep the other one?
4. Your Wi-Fi network sends RAs with M=0, O=0, A=1 but no RDNSS option. What will clients be able to do and what will be missing?
5. Your site has `2001:db8:acad::/56`. How many `/64` segments can you create, and how would you split it so that two floors can each be summarized as one route?
6. After deploying a strict firewall, IPv6 users report that web pages start loading and then hang on large images. Which ICMPv6 message is probably being dropped, and why does that cause the symptom?

## References
- [RFC 8200](https://www.rfc-editor.org/rfc/rfc8200) — Internet Protocol, Version 6 (IPv6) Specification.
- [RFC 4291](https://www.rfc-editor.org/rfc/rfc4291) — IP Version 6 Addressing Architecture.
- [RFC 5952](https://www.rfc-editor.org/rfc/rfc5952) — A Recommendation for IPv6 Address Text Representation.
- [RFC 3849](https://www.rfc-editor.org/rfc/rfc3849) — IPv6 Address Prefix Reserved for Documentation.
- [RFC 4193](https://www.rfc-editor.org/rfc/rfc4193) — Unique Local IPv6 Unicast Addresses.
- [RFC 4007](https://www.rfc-editor.org/rfc/rfc4007) — IPv6 Scoped Address Architecture.
- [RFC 4443](https://www.rfc-editor.org/rfc/rfc4443) — Internet Control Message Protocol (ICMPv6) for the Internet Protocol Version 6 (IPv6) Specification.
- [RFC 8201](https://www.rfc-editor.org/rfc/rfc8201) — Path MTU Discovery for IP version 6.
- [RFC 4861](https://www.rfc-editor.org/rfc/rfc4861) — Neighbor Discovery for IP version 6 (IPv6).
- [RFC 4862](https://www.rfc-editor.org/rfc/rfc4862) — IPv6 Stateless Address Autoconfiguration.
- [RFC 7217](https://www.rfc-editor.org/rfc/rfc7217) — A Method for Generating Semantically Opaque Interface Identifiers with IPv6 Stateless Address Autoconfiguration (SLAAC).
- [RFC 8064](https://www.rfc-editor.org/rfc/rfc8064) — Recommendation on Stable IPv6 Interface Identifiers.
- [RFC 8981](https://www.rfc-editor.org/rfc/rfc8981) — Temporary Address Extensions for Stateless Address Autoconfiguration in IPv6.
- [RFC 8106](https://www.rfc-editor.org/rfc/rfc8106) — IPv6 Router Advertisement Options for DNS Configuration.
- [RFC 8415](https://www.rfc-editor.org/rfc/rfc8415) — Dynamic Host Configuration Protocol for IPv6 (DHCPv6).
- [RFC 2464](https://www.rfc-editor.org/rfc/rfc2464) — Transmission of IPv6 Packets over Ethernet Networks.
- [RFC 6177](https://www.rfc-editor.org/rfc/rfc6177) — IPv6 Address Assignment to End Sites.
- [RFC 7421](https://www.rfc-editor.org/rfc/rfc7421) — Analysis of the 64-bit Boundary in IPv6 Addressing.
- [RFC 6164](https://www.rfc-editor.org/rfc/rfc6164) — Using 127-Bit IPv6 Prefixes on Inter-Router Links.
- [RIPE-690](https://www.ripe.net/publications/docs/ripe-690/) — Best Current Operational Practice for Operators: IPv6 prefix assignment for end-users.
- [RFC 3596](https://www.rfc-editor.org/rfc/rfc3596) — DNS Extensions to Support IP Version 6.
- [RFC 6724](https://www.rfc-editor.org/rfc/rfc6724) — Default Address Selection for Internet Protocol Version 6 (IPv6).
- [RFC 8305](https://www.rfc-editor.org/rfc/rfc8305) — Happy Eyeballs Version 2: Better Connectivity Using Concurrency.
- [RFC 6146](https://www.rfc-editor.org/rfc/rfc6146) — Stateful NAT64: Network Address and Protocol Translation from IPv6 Clients to IPv4 Servers.
- [RFC 6147](https://www.rfc-editor.org/rfc/rfc6147) — DNS64: DNS Extensions for Network Address Translation from IPv6 Clients to IPv4 Servers.
- [RFC 6052](https://www.rfc-editor.org/rfc/rfc6052) — IPv6 Addressing of IPv4/IPv6 Translators.
- [RFC 6877](https://www.rfc-editor.org/rfc/rfc6877) — 464XLAT: Combination of Stateful and Stateless Translation.
- [RFC 7526](https://www.rfc-editor.org/rfc/rfc7526) — Deprecating the Anycast Prefix for 6to4 Relay Routers.
- [RFC 6105](https://www.rfc-editor.org/rfc/rfc6105) — IPv6 Router Advertisement Guard.
- [RFC 7113](https://www.rfc-editor.org/rfc/rfc7113) — Implementation Advice for IPv6 Router Advertisement Guard (RA-Guard).
- [RFC 4890](https://www.rfc-editor.org/rfc/rfc4890) — Recommendations for Filtering ICMPv6 Messages in Firewalls.
- [RFC 7707](https://www.rfc-editor.org/rfc/rfc7707) — Network Reconnaissance in IPv6 Networks.
