LinuxXIX · Networking FoundationsIPv6
IPv6 addressing and subnetting
What you'll learn
- Read an IPv6 address in full and compressed form
- Identify the link-local and unique-local address ranges
- Configure a basic IPv6 address on a Linux interface
- Recognise the role of SLAAC and DHCPv6
Prerequisites
Verified against Ubuntu 24.04 LTS · Debian 12 (Bookworm) · RHEL 9.x · Rocky Linux 9.x · AlmaLinux 9.x · Linux kernel 6.1 LTS / 6.6 LTS · systemd 255+ · OpenSSH 8.7p1 (RHEL 9) / 9.6p1 (Ubuntu 24.04) · nftables 1.0.x · chrony 4.x · Pacemaker 2.1.x · Corosync 3.1.x · 2026-08-09
IPv6 is the successor to IPv4. Its 128-bit address space (about 3.4 x 10^38 addresses) makes subnet design trivial and removes the need for NAT in most cases. Modern Linux defaults to dual-stack (IPv4 and IPv6 simultaneously); disabling IPv6 entirely is no longer recommended.
Address format
An IPv6 address is 128 bits, written as eight colon-separated groups of four hex digits:
2001:0db8:85a3:0000:0000:8a2e:0370:7334
Leading zeros within a group may be dropped; one run of all-zero
groups may be replaced with :::
2001:db8:85a3::8a2e:370:7334
::1 # loopback
fe80::1 # link-local
:: can appear only once in an address (otherwise the parser
cannot know how many groups it represents).
Prefix length
IPv6 uses the same CIDR prefix notation as IPv4:
2001:db8:85a3::/48 # 16 bits for subnets
2001:db8:85a3:1::/64 # standard subnet (host has 64 bits)
fe80::/10 # link-local range
A standard subnet is /64. The host part is 64 bits - enough for SLAAC’s randomised interface identifier plus room to grow. Shorter prefixes (/48, /56) are typically what an ISP or datacentre operator allocates to a customer site.
Inspect IPv6 on a Linux host
ip -6 addr show
ip -6 route show
ip -6 neigh show
A modern Linux host with default settings will have at least:
::1/128on the loopback interface- A link-local address (fe80::/10) on every Ethernet interface
- A global address if the network provides one (via SLAAC or DHCPv6)
Special address ranges
| Range | Purpose |
|---|---|
::/128 | Unspecified address (like 0.0.0.0 in IPv4) |
::1/128 | Loopback (like 127.0.0.1 in IPv4) |
fe80::/10 | Link-local - automatic on every interface |
fd00::/8 | Unique local addresses (ULA) - private, like RFC 1918. This is the locally-assignable half of fc00::/7; the other half (fc00::/8) is reserved and must not be used. |
2000::/3 | Global unicast - the public internet |
ff00::/8 | Multicast - replaces IPv4 broadcast |
Link-local addresses are auto-generated from the NIC’s MAC address (with the universal/local bit flipped and the OUI modified). They are not routable; they only work on the local link.
RFC 4193 allocates the whole of fc00::/7 to ULAs, but splits
it on the L bit. Only the L=1 half, fd00::/8, is defined for
self-assignment. The L=0 half was reserved for a central
allocation authority that was never created, so fc00::/8 has
no defined meaning and nothing should be numbered out of it.
Within fd00::/8 the next 40 bits are a pseudo-random
global ID, and that is not decoration. Do not number a site
out of fd00::/48 because it is the easy one to type: two
organisations that both take the low-numbered prefixes will
collide the day they interconnect — a merger, an acquisition,
a site-to-site VPN — and the fix is renumbering both sides.
Generate the ID once per site and record it:
# 40 random bits after the fd prefix
printf 'fd%02x:%04x:%04x::/48\n' \
$((RANDOM % 256)) $((RANDOM % 65536)) $((RANDOM % 65536))
Configure an IPv6 address
ip -6 addr add 2001:db8:85a3:1::10/64 dev eth0
ip -6 route add default via 2001:db8:85a3:1::1 dev eth0
Persistent configuration belongs in Netplan, NetworkManager, or
systemd-networkd (covered in Part XX). Manual ip commands do
not survive a reboot.
SLAAC and DHCPv6
IPv6 hosts learn their address and default route via:
- SLAAC (Stateless Address Autoconfiguration, RFC 4862, built on the Neighbor Discovery machinery of RFC 4861): the router sends Router Advertisements (RAs) that advertise the prefix; the host combines the prefix with a self-generated interface identifier.
- DHCPv6: stateful assignment, similar to IPv4 DHCP. Used when you need specific DNS servers or other options.
Most networks run SLAAC for addressing and DHCPv6 just for
options (DNS, search domain). On Linux, systemd-networkd and
NetworkManager both support this.
Knowledge check
Knowledge check · 3 questions
Q1. What is the standard subnet prefix length for an IPv6 subnet?
Q2. Which IPv6 address is the loopback?
Q3. Disabling IPv6 on a Linux host is a safe way to reduce the attack surface and has no side effects.
Passing score: 75%. Answers are checked in this browser.