Sub topic 7
Link-local addresses
This chapter assumes you can read hexadecimal and compressed IPv6 notation, understand prefix length, and know what a router, switch, and default gateway do. It builds on the earlier chapters on address types and prefixes.
What a link-local address is
A link-local address is an IPv6 unicast address that is valid on one link only. A link is a single Layer 2 segment, such as one Ethernet LAN, one VLAN, or one point-to-point connection. Routers never forward packets whose source or destination is link-local. Two hosts on the same link can always talk using these addresses, with no router, no DHCP server, and no configuration.
Every IPv6-enabled interface must have a link-local address. The IPv6 stack creates it as soon as the interface comes up. This differs from IPv4, where the comparable 169.254.0.0/16 range is a fallback used only when DHCP fails. In IPv6, the link-local address is a permanent part of how the protocol works.
Prefix and structure
Link-local addresses belong to fe80::/10. The first 10 bits are fixed at 1111111010, so the range covers fe80:: through febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff.
The standard says the next 54 bits must be zero. In practice every link-local address therefore looks like this:
| Bits | Value | Purpose |
|---|---|---|
| 1–10 | `1111111010` | Link-local prefix `fe80::/10` |
| 11–64 | all zeros | Fixed padding |
| 65–128 | interface identifier | Identifies the interface on the link |
Operators therefore write the prefix as fe80::/64. You will almost always see addresses of the form fe80:: followed by four groups. The /10 describes the reserved range, and the /64 describes what is actually in use.
How the interface identifier is chosen
The last 64 bits are the interface identifier (IID). Hosts use one of several methods:
- Modified EUI-64: derived from the MAC address. Insert
ff:fein the middle of the 48-bit MAC and flip the universal/local bit (the second-lowest bit of the first byte). - Stable opaque identifiers: a hash of the prefix, interface name, and a secret key. The value is stable on one network but does not expose the MAC address. Most modern operating systems use this by default.
- Random: some systems generate a random IID, and the address may change.
- Manual: an administrator sets it, for example
fe80::1on a router interface so that the next hop is easy to remember.
The following function builds the EUI-64 link-local address from a MAC address:
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 02:1a:2b:ff:fe:3c:4d:5e. The leading 00 changes to 02 because of the flipped bit, and the compressed result drops the leading zero of 021a.
Duplicate Address Detection
Before an interface uses a new address, including a link-local one, it runs Duplicate Address Detection (DAD). The host sends a Neighbor Solicitation (NS) for its own tentative address. It sends the message from the unspecified address :: to the solicited-node multicast group derived from that address. If another host replies, the address is already taken and the interface must not use it. If nothing replies, the address becomes preferred.
Because IIDs derived from MAC addresses or secret hashes rarely collide, DAD almost always succeeds. It still runs every time, and it is why a new address is briefly marked tentative in the output of the tools.
What link-local addresses are used for
Many core IPv6 functions depend on them:
- Neighbor Discovery: Router Solicitations, Router Advertisements, and Neighbor Solicitations use link-local source addresses. A host can only listen for a router before it has any global address.
- Default gateways: a host learns its default router as the router's link-local address. The routing table shows
via fe80::...instead of a global address. A router can be renumbered without breaking this, because its link-local address stays the same. - Routing protocols: OSPFv3 and IS-IS for IPv6 form adjacencies using link-local addresses. BGP sessions sometimes use them on point-to-point links.
- Local services: protocols such as mDNS and local discovery often use link-local addresses plus multicast.
The zone identifier
The same fe80::/64 prefix exists on every link. A host with two interfaces, for example eth0 and wlan0, can have fe80::1 reachable on both. The address alone does not say which link to use. IPv6 solves this with a zone identifier (also called scope ID), written after a percent sign:
ping -6 -c 3 fe80::21a:2bff:fe3c:4d5e%eth0
ip -6 addr show dev eth0 scope link
ip -6 route showOn Linux the zone is the interface name. On Windows it is the interface index, such as fe80::1%12. The %zone suffix is local to your host. It is never sent in a packet, and a different machine will use a different name for the same link.
Python 3.9 and later accepts and keeps the zone:
import ipaddress
a = ipaddress.ip_address("fe80::1%eth0")
print(a) # fe80::1%eth0
print(a.scope_id) # eth0
print(a.is_link_local) # TrueClassifying addresses
You can test whether an address is link-local from its prefix, which separates it from loopback, unique local, and multicast addresses:
import ipaddress
for text in ["::1", "fe80::1", "fd12:3456:789a::1", "ff02::1"]:
a = ipaddress.ip_address(text)
print(text, a.is_loopback, a.is_link_local, a.is_private, a.is_multicast)
# ::1 True False True False
# fe80::1 False True True False
# fd12:3456:789a::1 False False True False
# ff02::1 False False False TrueCommon errors
- Missing zone ID.
ping fe80::1on a multi-homed host fails with an error such as "invalid argument", because the system cannot pick a link. Add%eth0. - Using link-local addresses in DNS. A DNS record for a link-local address is useless to hosts on other links. Publish global or unique local addresses instead.
- Assuming the router's address is global. Seeing
via fe80::...inip -6 route showis normal. It does not mean the route is broken. - Filtering too much. A firewall that drops all ICMPv6 on the local link breaks DAD and Neighbor Discovery. Allow ICMPv6 types for these functions on link-local scope.
- Treating
fe80::/10as a /10 subnet. The usable addresses sit infe80::/64. Never plan subnets inside it.
Exercise
A host has interfaces eth0 and eth1. Both show the address fe80::1. Why can the host still tell the interfaces apart, and what must you add to the address when you ping a neighbor on eth1?
Show answer
Link-local addresses only need to be unique per link, and the host keeps a separate zone (scope) for each interface. Add the zone identifier, for example ping -6 fe80::1%eth1 on Linux, so the system knows which link to send the packet on.
Exercise
Compute the link-local address that modified EUI-64 produces for the MAC address 3c:22:fb:10:20:30.
Show answer
Flip the universal/local bit of the first byte: 0x3c XOR 0x02 = 0x3e. Insert ff:fe in the middle to get 3e22:fbff:fe10:2030. Prefix it with fe80:: to get fe80::3e22:fbff:fe10:2030.