Showing raw Markdown: the renderer could not load.
## Goal
Find the IPv6 addresses your computer already has, identify the type and scope of each one, watch Neighbor Discovery fill the neighbor cache, and use Python to compress, classify and plan IPv6 addresses. You don't need IPv6 from your Internet provider: everything on the link works with link-local addresses.
## Objectives
- List your interfaces' IPv6 addresses and identify each one's type and scope (link-local, global unicast, ULA, loopback), including temporary addresses.
- Read the IPv6 routing table and find the default router learned from Router Advertisements.
- Inspect the neighbor cache and see Neighbor Discovery Protocol (NDP) add entries.
- Reach link-local and multicast destinations using a zone ID.
- Use Python's `ipaddress` module to apply RFC 5952, classify addresses, derive solicited-node multicast addresses and split a `/48` into `/64` subnets.
## Prerequisites
- A computer running a current version of Linux, macOS or Windows 10/11, with IPv6 enabled (the default on all three).
- Python 3.8 or later (`python3 --version`; on Windows, `py --version`). Only the standard library is used.
- A terminal. No administrator or `sudo` rights are needed: every command in this lab only reads state.
- Connection to a network you own or are allowed to use, such as your home network. A network with IPv6 from the Internet provider is a bonus, not a requirement.
- [The IPv6 lesson](lesson.md) of this module, especially address types, NDP and SLAAC.
> [!WARNING]
> Step 5 sends a ping to the all-nodes multicast address `ff02::1`, which reaches every device on your link. Do it only on your own network (for example, at home) or with the network owner's permission. Don't run it on public, corporate or school networks without authorization. The lab makes no configuration changes; it only creates one folder with a Python file, which you delete at the end.
> [!NOTE]
> The outputs below use documentation values: `2001:db8::/32` (RFC 3849) for global addresses, `fd8f:3c2a:61e4::/48` for the ULA, and MAC addresses from the RFC 7042 documentation range. Your real addresses, interface names and lifetimes will be different. If you share your results, replace your global addresses first: they identify your network.
## Architecture
<figure class="diagram" style="--dg-w: 920px"><svg xmlns="http://www.w3.org/2000/svg" class="dg" viewBox="0 0 920 370" width="920" height="370" role="img" aria-labelledby="ipv6-lab-architecture-title ipv6-lab-architecture-desc" font-family="Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif" xml:lang="en">
<title id="ipv6-lab-architecture-title">Lab architecture: everything happens on your own link</title>
<desc id="ipv6-lab-architecture-desc">Your computer, the home router and other devices share one link. The computer has a link-local address fe80:: with a zone ID for its interface, and a global address in a /64 such as 2001:db8:acad:10::/64 only if the provider supplies IPv6. The router, for example fe80::1, sends Router Advertisements to ff02::1. The computer and router exchange Neighbor Solicitations and Advertisements. Pinging ff02::1 with the interface zone ID reaches every device on the link. The Internet connection through the router is optional for this lab.</desc>
<rect class="dg-bg" x="0.5" y="0.5" width="919" height="369" rx="16" fill="#ffffff" stroke="#e3e3dd"/>
<g class="dg-l2"><rect class="dg-tint" x="20" y="20" width="720" height="330" rx="16" fill="#f1f7f3" stroke="#a1ccb1" stroke-width="1.2" stroke-dasharray="6 5"/>
<g class="dg-icon" transform="translate(36 33) scale(0.7500)" fill="none" stroke="#15803d" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h.01"/><path d="M2 8.82a15 15 0 0 1 20 0"/><path d="M5 12.86a10 10 0 0 1 14 0"/><path d="M8.5 16.43a5 5 0 0 1 7 0"/></g>
<text x="62" y="47" font-size="13" class="dg-ink" fill="#15803d" font-weight="700">Your link: home LAN or Wi-Fi, one network segment</text></g>
<rect class="dg-card" x="44" y="70" width="280" height="140" rx="12" fill="#ffffff" stroke="#cfcfc8"/>
<g class="dg-icon-neutral" transform="translate(60 86) scale(1.2500)" fill="none" stroke="#17171c" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16"/></g>
<text x="102" y="107" font-size="15" class="dg-text" fill="#17171c" font-weight="700">Your computer</text>
<text x="62" y="138" font-size="12.5" class="dg-text" fill="#17171c" font-weight="500" font-family="JetBrains Mono, ui-monospace, Menlo, Consolas, monospace">fe80::…%<iface></text>
<text x="62" y="158" font-size="12.5" class="dg-text" fill="#17171c" font-weight="500" font-family="JetBrains Mono, ui-monospace, Menlo, Consolas, monospace">2001:db8:acad:10::…/64</text>
<text x="62" y="178" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">(only if your ISP provides IPv6)</text>
<rect class="dg-card" x="474" y="70" width="244" height="140" rx="12" fill="#ffffff" stroke="#cfcfc8"/>
<g class="dg-icon-neutral" transform="translate(490 86) scale(1.2500)" fill="none" stroke="#17171c" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="8" x="2" y="14" rx="2"/><path d="M6.01 18H6"/><path d="M10.01 18H10"/><path d="M15 10v4"/><path d="M17.84 7.17a4 4 0 0 0-5.66 0"/><path d="M20.66 4.34a8 8 0 0 0-11.31 0"/></g>
<text x="532" y="107" font-size="15" class="dg-text" fill="#17171c" font-weight="700">Home router</text>
<text x="492" y="138" font-size="12.5" class="dg-text" fill="#17171c" font-weight="500" font-family="JetBrains Mono, ui-monospace, Menlo, Consolas, monospace">fe80::1 (example)</text>
<g class="dg-l7"><rect class="dg-tint" x="490" y="160" width="218" height="26" rx="13" fill="#f0eafb" stroke="#bd9eee" stroke-width="1.2"/><text x="599" y="177.5" font-size="12" class="dg-ink" fill="#6d28d9" font-weight="700" text-anchor="middle">Sends Router Advertisements</text></g>
<rect class="dg-card" x="44" y="262" width="280" height="72" rx="12" fill="#ffffff" stroke="#cfcfc8"/>
<g class="dg-icon-neutral" transform="translate(60 278) scale(1.2500)" fill="none" stroke="#17171c" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect width="10" height="14" x="3" y="8" rx="2"/><path d="M5 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-2.4"/><path d="M8 18h.01"/></g>
<text x="102" y="299" font-size="15" class="dg-text" fill="#17171c" font-weight="700">Other devices</text>
<text x="102" y="318" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">Phones, TVs, printers…</text>
<g class="dg-l7"><path class="dg-stroke" d="M474 112H330" stroke="#6d28d9" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g>
<g class="dg-l7"><path class="dg-stroke" d="M335 106l-8 6 8 6" stroke="#6d28d9" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g>
<g class="dg-l7"><rect class="dg-bg-plain" x="345.403" y="100" width="109.195" height="24" rx="12" fill="#ffffff"/><text x="400" y="116.5" font-size="11.5" class="dg-ink" fill="#6d28d9" font-weight="600" text-anchor="middle" font-family="JetBrains Mono, ui-monospace, Menlo, Consolas, monospace">RA to ff02::1</text></g>
<g class="dg-l3"><path class="dg-stroke" d="M328 172H470" stroke="#b45309" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g>
<g class="dg-l3"><path class="dg-stroke" d="M463 166l8 6-8 6" stroke="#b45309" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g>
<g class="dg-l3"><path class="dg-stroke" d="M335 166l-8 6 8 6" stroke="#b45309" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g>
<g class="dg-l3"><rect class="dg-bg-plain" x="368.46" y="160" width="63.08" height="24" rx="12" fill="#ffffff"/><text x="400" y="176.5" font-size="11.5" class="dg-ink" fill="#b45309" font-weight="600" text-anchor="middle">NS / NA</text></g>
<g class="dg-l1"><path class="dg-stroke" d="M150 210V256" stroke="#0369a1" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="7 6"/></g>
<g class="dg-l1"><path class="dg-stroke" d="M144 249l6 8 6-8" stroke="#0369a1" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g>
<g class="dg-l1"><rect class="dg-bg-plain" x="160.85" y="222" width="158.3" height="24" rx="12" fill="#ffffff"/><text x="240" y="238.5" font-size="11.5" class="dg-ink" fill="#0369a1" font-weight="600" text-anchor="middle" font-family="JetBrains Mono, ui-monospace, Menlo, Consolas, monospace">ping ff02::1%<iface></text></g>
<path class="dg-line" d="M718 140H798" stroke="#cfcfc8" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="7 6"/>
<path class="dg-line" d="M791 134l8 6-8 6" stroke="#cfcfc8" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
<circle class="dg-card" cx="846" cy="140" r="40" fill="#ffffff" stroke="#cfcfc8"/>
<g class="dg-icon-neutral" transform="translate(828 122) scale(1.5000)" fill="none" stroke="#17171c" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></g>
<text x="846" y="204" font-size="14" class="dg-text" fill="#17171c" font-weight="700" text-anchor="middle">Internet</text>
<text x="846" y="222" font-size="12.5" class="dg-muted" fill="#5c5c68" font-weight="500" text-anchor="middle">(optional)</text>
</svg></figure>
*Figure 1. Everything in this lab happens on your own link. Your computer needs a link-local address only; a global address appears only if your ISP provides IPv6.*
Everything you do happens on your own link. Routers never forward link-local or `ff02::` traffic, so nothing in this lab leaves your network.
## Steps
### Step 1 — Create a working folder
You will keep a small Python helper here, so cleanup is one command at the end.
Linux and macOS:
```bash
mkdir -p ~/ipv6-lab && cd ~/ipv6-lab
```
Windows (PowerShell):
```powershell
New-Item -ItemType Directory -Force "$HOME\ipv6-lab" | Out-Null; Set-Location "$HOME\ipv6-lab"
```
No output is expected.
### Step 2 — List your IPv6 addresses
Every IPv6-enabled interface has at least a link-local address, and usually several more. Listing them is the first thing you do when troubleshooting IPv6.
Linux:
```bash
ip -6 addr show
```
macOS (`<iface>` is usually `en0`):
```bash
ifconfig <iface> inet6
```
Windows:
```powershell
netsh interface ipv6 show addresses
```
`<iface>` is the name of your active network interface. On Linux it is shown in the `ip` output (for example `eth0`, `enp3s0`, `wlan0` or `wlp2s0`); on macOS, `en0` is usually Wi-Fi or the built-in Ethernet.
Expected output on Linux, on a network with IPv6 from the provider (yours will differ):
```text
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 state UNKNOWN qlen 1000
inet6 ::1/128 scope host noprefixroute
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000
inet6 2001:db8:acad:10:91d4:2e6b:c07a:3f58/64 scope global temporary dynamic
valid_lft 85912sec preferred_lft 13912sec
inet6 2001:db8:acad:10:4c3e:9b12:a7f0:6d21/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 86395sec preferred_lft 14395sec
inet6 fd8f:3c2a:61e4:10:5a7e:21c9:8b04:e3f6/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 86395sec preferred_lft 14395sec
inet6 fe80::4c3e:9b12:a7f0:6d21/64 scope link noprefixroute
valid_lft forever preferred_lft forever
```
On macOS, look for the keywords `secured` (stable privacy address), `temporary` and `autoconf` (built with SLAAC); link-local addresses are shown with their zone, as in `fe80::…%en0`. On Windows, the `Addr Type` column shows `Public` (stable), `Temporary` and `Other` (link-local), and link-local addresses end with `%<index>`.
If your provider has no IPv6, you'll see only `::1` and an `fe80::` address. That's enough for the rest of the lab.
### Step 3 — Identify each address's type and scope
Copy this table into your notes and fill it in for every address from Step 2. Use the lesson's address-type table and these clues from the Linux output:
| Linux keyword | Meaning |
|---|---|
| `scope host` | Valid only inside this machine (`::1`). |
| `scope link` | Link-local (`fe80::/10`). |
| `scope global` | Global unicast **or** ULA: Linux reports both as global; check the prefix (`2000::/3` vs `fd00::/8`). |
| `temporary` | A temporary (privacy) address from RFC 8981, used for outgoing connections. |
| `mngtmpaddr` | The stable address from which the kernel manages temporary addresses. |
| `dynamic` | Learned automatically (SLAAC or DHCPv6) and has lifetimes; static addresses show `forever`. |
| `tentative` / `dadfailed` | Duplicate address detection is still running / found a duplicate. |
| `deprecated` | Preferred lifetime expired: kept for existing connections, not used for new ones. |
| Address | Prefix length | Type | Scope | How it was configured |
|---|---|---|---|---|
| `::1` | `/128` | Loopback | Host | Built in |
| `fe80::4c3e:9b12:a7f0:6d21` | `/64` | Link-local | Link | Generated at link up |
| `2001:db8:acad:10:4c3e:9b12:a7f0:6d21` | `/64` | Global unicast, stable | Global | SLAAC |
| `2001:db8:acad:10:91d4:2e6b:c07a:3f58` | `/64` | Global unicast, temporary | Global | SLAAC (RFC 8981) |
| `fd8f:3c2a:61e4:10:5a7e:21c9:8b04:e3f6` | `/64` | Unique local (ULA) | Global (routed only inside the site) | SLAAC |
> [!TIP]
> Look at the interface ID of your link-local address. If it contains `ff:fe` in the middle (for example `fe80::200:5eff:fe00:5310`), your system uses modified EUI-64, which embeds your MAC address. A random-looking IID means stable privacy or random IIDs are in use.
### Step 4 — Find your default router
IPv6 hosts learn their default router from Router Advertisements, never from DHCPv6. The routing table shows where the route came from.
Linux:
```bash
ip -6 route show
```
macOS:
```bash
netstat -rn -f inet6 | grep -i default
```
Windows:
```powershell
netsh interface ipv6 show route
```
Expected output on Linux (with an IPv6 router on the link):
```text
2001:db8:acad:10::/64 dev eth0 proto ra metric 100 pref medium
fd8f:3c2a:61e4:10::/64 dev eth0 proto ra metric 100 pref medium
fe80::/64 dev eth0 proto kernel metric 1024 pref medium
default via fe80::1 dev eth0 proto ra metric 100 pref medium
```
Note three things:
- The default route's next hop is a **link-local** address (`fe80::1` here; on many home routers it's a long EUI-64 or random address) plus an interface (`dev eth0`). That's why link-local addresses need a zone.
- `proto ra` means the route was learned from a Router Advertisement.
- The on-link `/64` routes come from the RA's prefix information (the L flag).
Write down your router's link-local address and your interface name. If there is no `default` line, your network has no IPv6 router; continue anyway and skip the gateway ping in Step 5.
### Step 5 — Reach your link with multicast and link-local addresses
Now generate a little NDP traffic and see it in the neighbor cache. First, look at the cache as it is.
Linux:
```bash
ip -6 neigh show
```
macOS:
```bash
ndp -an
```
Windows:
```powershell
netsh interface ipv6 show neighbors
```
Then ping the **all-nodes** multicast group on your link. Every IPv6 device on the link receives it; the ones configured to answer will reply from their link-local addresses. The `%<iface>` zone ID tells the system which link to use.
Linux (iputils; on older systems use `ping6 -c 2 ff02::1%<iface>`):
```bash
ping -c 2 ff02::1%<iface>
```
macOS:
```bash
ping6 -c 2 ff02::1%<iface>
```
Expected output on Linux (one line per device that answers; extra replies to the same sequence number are marked `DUP!`):
```text
PING ff02::1%eth0 (ff02::1%eth0) 56 data bytes
64 bytes from fe80::4c3e:9b12:a7f0:6d21%eth0: icmp_seq=1 ttl=64 time=0.062 ms
64 bytes from fe80::1%eth0: icmp_seq=1 ttl=64 time=0.814 ms (DUP!)
64 bytes from fe80::200:5eff:fe00:5325%eth0: icmp_seq=1 ttl=64 time=3.21 ms (DUP!)
64 bytes from fe80::4c3e:9b12:a7f0:6d21%eth0: icmp_seq=2 ttl=64 time=0.058 ms
...
```
The first reply often comes from your own machine, which is also a member of `ff02::1`. Many devices, including Windows with its default firewall rules, don't answer pings, so seeing only your own address is normal. `ttl=` in the output is the IPv6 Hop Limit.
> [!NOTE]
> On Windows, the zone ID is the numeric interface index (shown as `%<index>` after the link-local addresses in Step 2, or in the `Idx` column of `netsh interface ipv6 show interfaces`). `ping -n 2 ff02::1%<index>` is accepted, but Windows `ping` generally doesn't display replies to a multicast destination. On Windows, skip the multicast ping and do the gateway ping below.
Next, ping your default router's link-local address from Step 4:
Linux / macOS (`ping6` on macOS):
```bash
ping -c 2 <router-link-local>%<iface>
```
Windows:
```powershell
ping -n 2 <router-link-local>%<index>
```
`<router-link-local>` is the address after `via` in Step 4 (for example `fe80::1`); `<index>` is your interface index on Windows.
Expected output on Linux:
```text
PING fe80::1%eth0 (fe80::1%eth0) 56 data bytes
64 bytes from fe80::1%eth0: icmp_seq=1 ttl=64 time=0.791 ms
64 bytes from fe80::1%eth0: icmp_seq=2 ttl=64 time=0.705 ms
```
Now look at the neighbor cache again with the same command as before:
```text
fe80::1 dev eth0 lladdr 00:00:5e:00:53:01 router REACHABLE
fe80::200:5eff:fe00:5325 dev eth0 lladdr 00:00:5e:00:53:25 STALE
```
Each entry maps an IPv6 address to a MAC address (`lladdr`), learned with Neighbor Solicitation and Neighbor Advertisement messages. `router` marks a neighbor that sends RAs. `REACHABLE` means recently confirmed; `STALE` means it will be re-checked the next time it's used. Compare the entries with what you saw before the pings.
### Step 6 — Build a small IPv6 helper in Python
Doing RFC 5952 compression, classification and solicited-node calculation by hand is error-prone. Python's standard `ipaddress` module does the arithmetic; the helper below adds the classification from the lesson.
Save this as `ipv6_tool.py` in your `ipv6-lab` folder (with any text editor):
```python
"""IPv6 helper for the CloudAcademia IPv6 lab (standard library only)."""
import ipaddress
import sys
# Most specific first: the first match wins.
TYPES = [
("::/128", "unspecified"),
("::1/128", "loopback"),
("::ffff:0:0/96", "IPv4-mapped"),
("64:ff9b::/96", "NAT64 well-known prefix"),
("fe80::/10", "link-local unicast"),
("fc00::/7", "unique local (ULA)"),
("ff00::/8", "multicast"),
("2001:db8::/32", "global unicast (documentation)"),
("2000::/3", "global unicast"),
]
TYPES = [(ipaddress.ip_network(net), name) for net, name in TYPES]
MCAST_SCOPES = {1: "interface-local", 2: "link-local", 5: "site-local", 8: "organization-local", 14: "global"}
def parse(text):
"""Return (address, zone ID or None). Accepts fe80::1%eth0 and 2001:db8::1/64."""
text = text.split("/")[0]
addr, _, zone = text.partition("%")
return ipaddress.IPv6Address(addr), zone or None
def classify(addr):
for net, name in TYPES:
if addr in net:
if name == "multicast":
scope = int(addr) >> 112 & 0xF # 4th hex digit: ff0X::
return f"multicast, {MCAST_SCOPES.get(scope, f'scope {scope:x}')} scope"
return name
return "other / reserved"
def solicited_node(addr):
"""ff02::1:ff00:0/104 + the last 24 bits of the unicast address."""
return ipaddress.IPv6Address(int(ipaddress.IPv6Address("ff02::1:ff00:0")) | (int(addr) & 0xFFFFFF))
def describe(text):
addr, zone = parse(text)
print(f"input : {text}")
print(f"compressed : {addr.compressed}")
print(f"exploded : {addr.exploded}")
print(f"type : {classify(addr)}")
if zone:
print(f"zone ID : {zone}")
if not (addr.is_multicast or addr.is_unspecified or addr.is_loopback or addr.ipv4_mapped):
print(f"solicited-node : {solicited_node(addr)}")
print()
def plan(prefix, count):
net = ipaddress.IPv6Network(prefix)
subnets = net.subnets(new_prefix=64)
print(f"{net} contains {2 ** (64 - net.prefixlen)} /64 subnets. The first {count}:")
for _, sub in zip(range(count), subnets):
print(f" {sub}")
print()
def selftest():
def addr(text):
return parse(text)[0]
assert addr("2001:0DB8:0000:0000:0000:ff00:0042:8329").compressed == "2001:db8::ff00:42:8329"
assert addr("2001:db8:0:0:1:0:0:1").compressed == "2001:db8::1:0:0:1"
assert addr("2001:db8:0:1:1:1:1:1").compressed == "2001:db8:0:1:1:1:1:1"
assert parse("fe80::1%eth0") == (ipaddress.IPv6Address("fe80::1"), "eth0")
assert classify(addr("fe80::1%eth0")) == "link-local unicast"
assert classify(addr("fd8f:3c2a:61e4:10::1")) == "unique local (ULA)"
assert classify(addr("ff02::2")) == "multicast, link-local scope"
assert str(solicited_node(addr("2001:db8:acad:10:4c3e:9b12:a7f0:6d21"))) == "ff02::1:fff0:6d21"
assert len(list(ipaddress.IPv6Network("2001:db8:acad::/56").subnets(new_prefix=64))) == 256
print("All self-tests passed.")
if __name__ == "__main__":
args = sys.argv[1:]
if not args:
sys.exit("usage: ipv6_tool.py ADDRESS... | --plan PREFIX [COUNT] | --selftest")
try:
if args[0] == "--selftest":
selftest()
elif args[0] == "--plan":
plan(args[1], int(args[2]) if len(args) > 2 else 4)
else:
for a in args:
describe(a)
except ValueError as err:
sys.exit(f"error: {err}")
```
A few notes on the code:
- `parse()` strips the zone ID and any prefix length before parsing. The zone is kept for display only.
- `classify()` uses its own table instead of `ipaddress` properties such as `is_global` and `is_private`, whose exact behaviour has changed between Python versions.
- `solicited_node()` applies the rule from the lesson: `ff02::1:ff` plus the last 24 bits.
Run the self-test (on Windows, use `py` instead of `python3` in this and the following steps):
```bash
python3 ipv6_tool.py --selftest
```
Expected output:
```text
All self-tests passed.
```
### Step 7 — Compress, expand and classify addresses
Run the helper on a mix of addresses, written the long way and the short way:
```bash
python3 ipv6_tool.py 2001:0DB8:0000:0000:0000:ff00:0042:8329 fe80::4c3e:9b12:a7f0:6d21%eth0 fd8f:3c2a:61e4:10::25 ff02::1 ::1
```
Expected output:
```text
input : 2001:0DB8:0000:0000:0000:ff00:0042:8329
compressed : 2001:db8::ff00:42:8329
exploded : 2001:0db8:0000:0000:0000:ff00:0042:8329
type : global unicast (documentation)
solicited-node : ff02::1:ff42:8329
input : fe80::4c3e:9b12:a7f0:6d21%eth0
compressed : fe80::4c3e:9b12:a7f0:6d21
exploded : fe80:0000:0000:0000:4c3e:9b12:a7f0:6d21
type : link-local unicast
zone ID : eth0
solicited-node : ff02::1:fff0:6d21
input : fd8f:3c2a:61e4:10::25
compressed : fd8f:3c2a:61e4:10::25
exploded : fd8f:3c2a:61e4:0010:0000:0000:0000:0025
type : unique local (ULA)
solicited-node : ff02::1:ff00:25
input : ff02::1
compressed : ff02::1
exploded : ff02:0000:0000:0000:0000:0000:0000:0001
type : multicast, link-local scope
input : ::1
compressed : ::1
exploded : 0000:0000:0000:0000:0000:0000:0000:0001
type : loopback
```
Check the output against the lesson:
- The first address is now lowercase, without leading zeros, and the run of three zero groups is `::`.
- The link-local address and its global counterpart from the lesson (`2001:db8:acad:10:4c3e:9b12:a7f0:6d21`) share the same last 24 bits, so they share one solicited-node group, `ff02::1:fff0:6d21`. One Neighbor Solicitation reaches the owner of both.
Now run it on **your own** addresses from Step 2 (paste them as they appear, with `/64` or `%<iface>` if present) and compare the `type` column with the table you filled in during Step 3. Don't paste your global addresses anywhere public.
Finally, try an invalid input (two `::`) to see what the parser rejects:
```bash
python3 ipv6_tool.py 2001:db8::1::2
```
Expected output:
```text
error: At most one '::' permitted in '2001:db8::1::2'
```
### Step 8 — Plan `/64` subnets from a site prefix
Use the worked example from the lesson: Example Corp has `2001:db8:acad::/48`. List the first `/64`s, then see how much a `/56` holds:
```bash
python3 ipv6_tool.py --plan 2001:db8:acad::/48 4
python3 ipv6_tool.py --plan 2001:db8:acad:1000::/56 3
```
Expected output:
```text
2001:db8:acad::/48 contains 65536 /64 subnets. The first 4:
2001:db8:acad::/64
2001:db8:acad:1::/64
2001:db8:acad:2::/64
2001:db8:acad:3::/64
2001:db8:acad:1000::/56 contains 256 /64 subnets. The first 3:
2001:db8:acad:1000::/64
2001:db8:acad:1001::/64
2001:db8:acad:1002::/64
```
The subnet ID is simply the fourth group. To pick the `/64` for a given subnet ID, index the list with the ID written in hexadecimal. In the lesson's plan, building 0 VLAN 10 is subnet ID `0010` and building 1 VLAN 10 is `1010`:
```bash
python3 -c "import ipaddress as i; s = list(i.ip_network('2001:db8:acad::/48').subnets(new_prefix=64)); print(s[0x0010], s[0x1010])"
```
Expected output:
```text
2001:db8:acad:10::/64 2001:db8:acad:1010::/64
```
Note that `s[0x0010]` is index 16, not 10: subnet IDs are hexadecimal.
## Verification
You have completed the lab if all of these are true:
| Check | Pass condition |
|---|---|
| Addresses listed | Your Step 3 table has at least `::1` and one `fe80::` address, each with the right type and scope. |
| Default router | You found the default route in Step 4 and can say whether it came from an RA (`proto ra` on Linux), or you confirmed there is no IPv6 router on your link. |
| Neighbor discovery | After Step 5, the neighbor cache has at least one entry it didn't have before (or your gateway is `REACHABLE`). |
| Zone IDs | A ping to a link-local or `ff02::` address worked with `%<iface>` (Linux/macOS) or `%<index>` (Windows). |
| Helper | `python3 ipv6_tool.py --selftest` prints `All self-tests passed.` |
| Planning | `python3 ipv6_tool.py --plan 2001:db8:acad::/56 1` reports `256 /64 subnets`. |
## Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Only `::1` and an `fe80::` address appear | Your network or provider doesn't offer IPv6, so no RA with a prefix arrives. | Nothing to fix: continue with link-local addresses. Global addresses are optional in this lab. |
| No `fe80::` address at all | IPv6 is disabled on the interface (for example by a VPN client or a hardening script). | Note it as a finding. Re-enabling IPv6 is a configuration change outside this read-only lab; ask whoever manages the machine. |
| `ping: Warning: IPv6 link-local address on ICMP datagram socket may require ifname or scope-id` and no replies | You pinged `fe80::…` or `ff02::1` without a zone ID. | Add `%<iface>` (Linux/macOS) or `%<index>` (Windows). |
| `ping: ff02::1%wlan1: Name or service not known` | The interface name after `%` doesn't exist. | Use the exact interface name from Step 2. |
| `ping6: command not found` (Linux) | Some recent distributions no longer ship a separate `ping6`; `ping` handles both. | Use `ping` (it detects IPv6 from the address; add `-6` if needed). |
| Multicast ping shows only your own address | Other devices don't answer echo requests to multicast (common with firewalls and some phones). | Normal. Ping your gateway's link-local address instead, then check the neighbor cache. |
| Address shows `dadfailed` | Another device on the link is using the same address. | Note which address and device; it is a real network problem worth reporting to the network owner. |
| `SyntaxError` or `AttributeError` when running the helper | Python older than 3.8, or a copy-paste error (lost indentation). | Check `python3 --version`; copy the code block again into a plain-text editor. |
## Challenge (optional)
Find out whether your computer's host firewall applies the same policy to IPv6 as to IPv4. On Linux, look at the nftables ruleset (does it use an `inet` table, or separate `ip` and `ip6` tables?); on Windows, compare the ICMPv4 and ICMPv6 rules in Windows Defender Firewall; on macOS, look at the Application Firewall and `pf` settings. Then check whether the rules would let ICMPv6 Packet Too Big (type 2) and the NDP messages (types 133–137) through, as RFC 4890 recommends. Some of these commands need administrator rights; only run them on your own machine, and don't change anything.
## Cleanup
The lab created only the `ipv6-lab` folder. The neighbor cache entries from Step 5 expire on their own.
Linux and macOS:
```bash
cd ~ && rm -r ~/ipv6-lab
```
Windows (PowerShell):
```powershell
Set-Location $HOME; Remove-Item -Recurse -Force "$HOME\ipv6-lab"
```
Delete any notes in which you pasted your real global IPv6 addresses if you no longer need them.
## What you learned
- Your computer already runs IPv6: every interface has a link-local address, and with an IPv6 router it also has stable and temporary global addresses (and sometimes a ULA).
- Linux shows the scope (`host`, `link`, `global`) and the origin (`temporary`, `mngtmpaddr`, `dynamic`) of each address; ULAs show as `global` scope, so check the prefix.
- The default route points to the router's link-local address and comes from Router Advertisements.
- Link-local and link-scope multicast addresses need a zone ID; NDP fills the neighbor cache as you talk to neighbors.
- Python's `ipaddress` module applies RFC 5952, expands addresses and splits prefixes into `/64` subnets; solicited-node addresses are `ff02::1:ff` plus the last 24 bits.