IPv6 Basics and Security Notes
Many networks "don't use IPv6", and yet every modern operating system turns it on by default, gives itself a link-local address and listens for routers. If the firewall, the IDS and the logging pipeline only understand IPv4, that is a second network running underneath the monitored one. This lesson covers what an analyst needs to read IPv6 traffic, and the security issues that come from IPv6 being present but unwatched. The protocol itself is taught in IPv6. Addresses here use the documentation prefix 2001:db8::/32 (RFC 3849), the IPv6 counterpart of the RFC 5737 ranges.
Addresses an analyst must recognise
| Prefix | Kind | Seen where |
|---|---|---|
::1/128 |
loopback | the host itself |
fe80::/10 |
link-local | every interface, always; never routed |
fc00::/7 (in practice fd00::/8) |
unique local (ULA) | internal networks, like RFC 1918 |
2000::/3 |
global unicast | the Internet |
ff00::/8 |
multicast (ff02::1 all nodes, ff02::2 all routers) |
neighbour discovery, routing |
2001:db8::/32 |
documentation | examples only |
::ffff:0:0/96 |
IPv4-mapped | dual-stack sockets |
Notation: eight groups of four hex digits; leading zeros in a group may be dropped, and one run of zero groups becomes ::. Compare and store addresses in their canonical form (RFC 5952), or a block list misses 2001:DB8:0:0::1 because it was written as 2001:db8::1.
import ipaddress as ipa
for text in ["2001:DB8:0:0:0:0:0:1", "fe80::200:ff:fe0a:a05", "fd12:3456:789a::10", "ff02::1", "::ffff:10.10.0.5"]:
a = ipa.ip_address(text)
kind = ("link-local" if a.is_link_local else "multicast" if a.is_multicast
else "IPv4-mapped " + str(a.ipv4_mapped) if a.ipv4_mapped
else "unique local" if a in ipa.ip_network("fc00::/7")
else "documentation" if a in ipa.ip_network("2001:db8::/32") else "global")
print(f"{text:<24} canonical {str(a):<22} {kind}")
# Modified EUI-64: the interface ID that older SLAAC builds from the MAC address
mac = "02:00:00:0a:0a:05"
b = bytearray(int(x, 16) for x in mac.split(":"))
b[0] ^= 0x02 # flip the U/L bit
iid = bytes(b[:3]) + b"\xff\xfe" + bytes(b[3:])
addr = ipa.IPv6Address(b"\xfe\x80" + bytes(6) + iid)
print("\nMAC", mac, "-> EUI-64 link-local", addr)2001:DB8:0:0:0:0:0:1 canonical 2001:db8::1 documentation
fe80::200:ff:fe0a:a05 canonical fe80::200:ff:fe0a:a05 link-local
fd12:3456:789a::10 canonical fd12:3456:789a::10 unique local
ff02::1 canonical ff02::1 multicast
::ffff:10.10.0.5 canonical ::ffff:10.10.0.5 IPv4-mapped 10.10.0.5
MAC 02:00:00:0a:0a:05 -> EUI-64 link-local fe80::ff:fe0a:a05
The last line shows why the old EUI-64 scheme was a privacy problem: the MAC address (…0a:0a:05) is readable inside the IPv6 address, and it stays the same on every network the device joins. Current systems use random, temporary interface IDs (RFC 8981) or stable opaque ones (RFC 7217).
The header and Neighbor Discovery
The IPv6 header is a fixed 40 bytes: version, traffic class, flow label, payload length, next header (the protocol number, or an extension header), hop limit (IPv6's TTL), and the two 16-byte addresses. There is no header checksum and no fragmentation by routers; options live in extension headers chained through "next header".
ARP is gone. Its job is done by Neighbor Discovery (NDP, RFC 4861), carried in ICMPv6:
| ICMPv6 type | Message | Role |
|---|---|---|
| 133 | Router Solicitation (RS) | "any routers here?" |
| 134 | Router Advertisement (RA) | "I am a router; use this prefix" (drives SLAAC) |
| 135 | Neighbor Solicitation (NS) | ARP request equivalent; also duplicate-address detection |
| 136 | Neighbor Advertisement (NA) | ARP reply equivalent |
| 137 | Redirect | "use this other router" |
Like ARP, none of these is authenticated by default (SEND, RFC 3971, adds signatures but is almost never deployed).
Attacks, as concepts
- Rogue Router Advertisements. Any host on the link can send RAs. Hosts then pick up a new default router (the attacker) or a new prefix, which puts the attacker in the middle of all IPv6 traffic, even on an "IPv4-only" network, because operating systems prefer IPv6 when it is available. Accidental rogue RAs (a misconfigured laptop sharing its connection) cause outages too.
- NA spoofing: the IPv6 version of ARP spoofing.
- Extension-header evasion: long chains of extension headers or fragments push the TCP header deep into the packet, past what some filters inspect (RFC 7112 requires the whole header chain in the first fragment).
- Unmonitored tunnels: Teredo, 6to4 and other transition mechanisms carry IPv6 inside IPv4 (UDP 3544, protocol 41) past IPv4-only inspection.
How it is detected
Router Advertisements should come only from your routers. The session writes a synthetic capture (fixed timestamps, documentation prefix) with one legitimate RA, one from an unknown host, and an ordinary neighbour solicitation, then lists every RA with its source:
python3 - <<'PY'
from scapy.all import Ether, IPv6, ICMPv6ND_RA, ICMPv6NDOptPrefixInfo, ICMPv6ND_NS, wrpcap
t0 = 1768471200.0
good = Ether(src="02:00:00:0a:0a:01", dst="33:33:00:00:00:01")/IPv6(src="fe80::1", dst="ff02::1")/ICMPv6ND_RA()/ICMPv6NDOptPrefixInfo(prefix="2001:db8:10::", prefixlen=64)
rogue = Ether(src="02:00:00:0a:0a:66", dst="33:33:00:00:00:01")/IPv6(src="fe80::66", dst="ff02::1")/ICMPv6ND_RA(routerlifetime=9000)/ICMPv6NDOptPrefixInfo(prefix="2001:db8:666::", prefixlen=64)
ns = Ether(src="02:00:00:0a:0a:05", dst="33:33:ff:00:00:01")/IPv6(src="fe80::5", dst="ff02::1:ff00:1")/ICMPv6ND_NS(tgt="fe80::1")
for i, p in enumerate([good, ns, rogue]):
p.time = t0 + i
wrpcap("nd.pcap", [good, ns, rogue])
PY
tshark -r nd.pcap -Y 'icmpv6.type == 134' -T fields -e frame.time_relative -e eth.src -e ipv6.src -e icmpv6.opt.prefix -e icmpv6.nd.ra.router_lifetime
echo "--- RAs not from the known router fe80::1:"
tshark -r nd.pcap -Y 'icmpv6.type == 134 && ipv6.src != fe80::1' -T fields -e eth.src -e ipv6.src0.000000000 02:00:00:0a:0a:01 fe80::1 2001:db8:10:: 1800
2.000000000 02:00:00:0a:0a:66 fe80::66 2001:db8:666:: 9000
--- RAs not from the known router fe80::1:
02:00:00:0a:0a:66 fe80::66
Other signs: hosts suddenly using a prefix you never assigned, a default route via an unknown link-local address (ip -6 route on Linux), tools such as ndpmon or rafixd, and traffic to UDP 3544 or IP protocol 41 at the perimeter.
How it is fixed
- RA Guard (RFC 6105) on access switches: RAs are only accepted on ports facing real routers. Pair it with DHCPv6 Guard and IPv6 source guard where available. Make sure the implementation also handles RAs hidden behind extension headers (RFC 7113).
- Monitor and filter IPv6 as you do IPv4: firewall rules, IDS rules and logging for both families. If a network really must not use IPv6, block it deliberately at the switch and the hosts rather than leaving it on and ignored.
- Block transition tunnels you don't use (protocol 41, UDP 3544) at the edge.
- Use privacy or stable-opaque interface IDs rather than EUI-64.
Pitfalls
- "We don't run IPv6": the hosts do, on every link, with link-local addresses and RA listening.
- String-matching IPv6 addresses instead of comparing parsed ones.
- Port-scanning IPv6 like IPv4. A /64 has addresses, so sweeping it is hopeless; attackers find IPv6 hosts through DNS, logs and neighbour caches, which is where you should look too.
Practice
1. Expand 2001:db8::a:5 fully.
2001:0db8:0000:0000:0000:0000:000a:0005. The :: stands for the five zero groups needed to make eight.
2. Why can a rogue RA attack a network that "only uses IPv4"?
Hosts have IPv6 enabled and accept RAs. Once one arrives, they configure a global address and a default route via the attacker, and prefer IPv6 for names that resolve to AAAA records (or for an attacker-supplied DNS server), so traffic moves to a path nobody monitors.
3. In the capture, the rogue RA has router lifetime 9000 s. Why does that matter for the response?
Hosts keep the rogue default router for up to 9000 seconds (2.5 hours) unless something overrides it. After blocking the source, you may need to send a legitimate RA, or the real router's RA with priority, and check hosts' routing tables.
Test yourself
Which protocol replaces ARP in IPv6?
- DHCPv6
- Neighbor Discovery (ICMPv6)
- IGMP
- OSPFv3
Which ICMPv6 message type is a Router Advertisement?
- 128
- 133
- 134
- 136
Which switch feature blocks Router Advertisements from host ports?
- Port mirroring
- RA Guard
- SYN cookies
- BPDU guard
Why was the EUI-64 interface ID a privacy problem?
- It is too short
- It embeds the device's MAC address, identical on every network
- It is not routable
- It disables encryption