Sub topic 12
Interface identifiers and privacy
This chapter assumes you can read compressed IPv6 notation, understand a /64 prefix, and know what a link-local address is. It covers how a host picks the low 64 bits of its address, why the oldest method leaks information, and what replaced it.
The interface identifier
An IPv6 unicast address on a normal subnet has two halves. The first 64 bits are the network prefix, which a router supplies. The last 64 bits are the interface identifier (IID), which the host usually chooses itself. The IID only has to be unique on the link. Duplicate Address Detection (DAD) checks this before the host uses the address.
SLAAC, covered in a later chapter, requires the IID to be exactly 64 bits. This is the main reason /64 is the standard subnet size. A subnet with a longer prefix, such as /80, breaks SLAAC.
A host can build its IID in several ways. The method decides whether the address reveals your hardware, whether it follows you between networks, and whether it changes over time.
Modified EUI-64
The original method derives the IID from the interface's 48-bit MAC address. The result is called modified EUI-64. It takes three steps:
- Split the MAC into its first three bytes (the vendor part, or OUI) and its last three bytes.
- Insert
ff:febetween them, giving 8 bytes. - Flip the universal/local bit. This is bit 0x02 of the first byte.
The flip exists for historical reasons. In a MAC address, 0 in this bit means "globally unique, assigned by the manufacturer". In an IID, the meaning is inverted so that a hand-typed address such as ::1 or ::5 has the bit at 0, which makes short manual addresses easier to write.
import ipaddress
def eui64_link_local(mac):
b = bytearray(int(x, 16) for x in mac.split(":"))
b[0] ^= 0x02 # flip the universal/local bit
iid = bytes(b[:3]) + b"\xff\xfe" + bytes(b[3:])
return ipaddress.IPv6Address(b"\xfe\x80" + bytes(6) + iid)
print(eui64_link_local("00:1a:2b:3c:4d:5e")) # fe80::21a:2bff:fe3c:4d5eThe MAC 00:1a:2b:3c:4d:5e becomes the IID 021a:2bff:fe3c:4d5e. Notice that ff:fe in the middle of an IID is a strong sign of an EUI-64 address.
Why EUI-64 is a privacy problem
An EUI-64 IID is built from a hardware address that never changes, so it has three problems:
- Tracking across networks. The IID stays the same when a laptop moves from home to a café to an office. Only the prefix changes. Any server that logs addresses can link those visits together.
- Hardware disclosure. The first three bytes identify the manufacturer, and the rest identify a specific device. Anyone who sees the address learns this.
- Easier scanning. Addresses built from a known vendor's OUI are far easier to guess than 64 random bits.
For these reasons, current guidance (RFC 8064) tells implementations not to use EUI-64 as the default way to generate IIDs.
Temporary addresses
Temporary addresses (RFC 4941, updated by RFC 8981) address the tracking problem. The host generates a random IID, combines it with the SLAAC prefix, and uses the result for outgoing connections. It replaces that address regularly.
The usual defaults are:
- A preferred lifetime of about one day. During this period the address can be used for new connections.
- A valid lifetime of about two days. After the preferred lifetime ends, existing connections can continue, but new ones use a newer address.
A host with temporary addresses normally holds several IPv6 addresses on one interface:
- a link-local address
- a stable address, which is used for inbound traffic
- one or more temporary addresses, which are preferred for outbound connections
The source address selection rules (RFC 6724) make the host prefer a temporary address when one is available and the feature is enabled.
Here is a small sketch of a random IID. Real operating systems also check for collisions with reserved IIDs and run DAD.
import ipaddress
import secrets
def temporary_address(prefix):
net = ipaddress.ip_network(prefix)
if net.prefixlen != 64:
raise ValueError("SLAAC needs a /64 prefix")
iid = bytearray(secrets.token_bytes(8))
iid[0] &= 0xFD # clear the universal/local bit: locally generated
return ipaddress.IPv6Address(net.network_address.packed[:8] + bytes(iid))
print(temporary_address("2001:db8:abcd:1::/64"))Stable opaque identifiers
Random temporary addresses have one drawback for servers, logs, and firewall rules: they change. A host often wants an address that stays the same on one network but cannot be linked across networks. RFC 7217 defines this. The IID is a hash of:
- the network prefix
- the interface name
- a network ID, such as the SSID
- a DAD counter
- a secret key that stays on the host
Because the prefix is an input, the IID changes on every network. Because the secret is also an input, an outsider cannot work out the MAC address or predict the IID from the prefix.
import hashlib
import ipaddress
def stable_opaque(prefix, ifname, secret, dad_counter=0):
net = ipaddress.ip_network(prefix)
if net.prefixlen != 64:
raise ValueError("SLAAC needs a /64 prefix")
net_bytes = net.network_address.packed[:8]
data = net_bytes + ifname.encode() + secret + bytes([dad_counter])
iid = hashlib.sha256(data).digest()[:8]
return ipaddress.IPv6Address(net_bytes + iid)
secret = b"keep-this-on-the-host-only"
print(stable_opaque("2001:db8:abcd:1::/64", "eth0", secret))
print(stable_opaque("2001:db8:ffff:9::/64", "eth0", secret))Run it and you get two unrelated IIDs for the same interface and secret. If DAD finds a collision, the host increments the counter and hashes again.
Comparing the methods
| Method | Source of the IID | Stable on one network | Same across networks | Typical use |
|---|---|---|---|---|
| Modified EUI-64 | MAC address | Yes | Yes | Legacy, some embedded devices |
| Temporary (RFC 8981) | Random, regenerated | No | No | Outgoing client traffic |
| Stable opaque (RFC 7217) | Hash with a secret | Yes | No | Stable default address |
| Manual or DHCPv6 | Administrator or server | Yes | Depends | Servers, routers |
Controlling the behavior on Linux
Linux exposes both choices as sysctl settings. addr_gen_mode selects how the stable address is built. use_tempaddr controls temporary addresses.
sysctl net.ipv6.conf.eth0.addr_gen_mode # 0 EUI-64, 1 none, 2 stable-privacy, 3 random
sysctl net.ipv6.conf.eth0.use_tempaddr # 0 off, 1 create, 2 create and prefer
ip -6 addr show dev eth0In ip -6 addr show, temporary addresses carry the temporary flag, and addresses from SLAAC carry dynamic. Windows and macOS use randomized IIDs by default for both address kinds, and Android and iOS do the same.
Common errors
- Allowing a server to use temporary addresses. Inbound connections need a stable target, and DNS records for a changing address go stale. Give servers a stable opaque, static, or DHCPv6 address and publish that in DNS.
- Writing firewall rules that match an EUI-64 IID. If the host is later updated or replaced, the IID changes and the rule no longer matches. Match on the prefix or use a managed address instead.
- Assuming
ff:fealways means EUI-64. A random or static IID can contain those bytes by chance. The pattern is a hint only. - Reading a DHCPv6 address as proof of privacy. The server hands out the address, but it can log the client's DUID, which is often derived from a MAC address.
- Forgetting the lifetimes. Temporary addresses expire. Long-lived connections that bind to one can break if the application does not handle address changes.
Exercise
A laptop's interface has the MAC address 3c:22:fb:10:20:30. Using modified EUI-64, what IID does it get, and why can the same laptop be tracked across networks if it uses this method?
Show answer
Insert ff:fe in the middle to get 3c:22:fb:ff:fe:10:20:30, then flip the 0x02 bit of the first byte: 0x3c becomes 0x3e. The IID is 3e22:fbff:fe10:2030. The IID depends only on the MAC address, which never changes, so every network the laptop joins sees the same low 64 bits and can link the visits together. Only the prefix differs.
Exercise
A web server uses SLAAC with temporary addresses enabled. Users report that its DNS name stops working every day or two. What is the cause, and what is a better configuration?
Show answer
DNS holds an address that was a temporary one, and that address expires after its valid lifetime, roughly two days. Outbound-preferred temporary addresses are meant to change. The server should use a stable address, such as a static one, a DHCPv6-assigned one, or a stable opaque (RFC 7217) SLAAC address, and publish only that address in DNS.