Sub topic 8
Unique local addresses
Unique local addresses (ULAs) are IPv6's counterpart to IPv4 private ranges such as 10.0.0.0/8. This chapter assumes you know prefix notation, the difference between global unicast and link-local addresses, and basic routing. Packets from ULAs are meant to stay inside your own network and are not routed on the public internet.
The fc00::/7 prefix
The block fc00::/7 is reserved for ULAs. In practice only the half fd00::/8 is used for locally assigned addresses. The fc00::/8 half was set aside for a possible central registry that never came into being. Treat every ULA you create as starting with fd.
A ULA has this layout:
| Field | Bits | Purpose |
|---|---|---|
| Prefix | 8 | `fd` |
| Global ID | 40 | Randomly generated |
| Subnet ID | 16 | Your own subnets |
| Interface ID | 64 | Identifies the host |
The 8-bit prefix, 40-bit global ID and 16-bit subnet ID together make a /64. Each site therefore gets a /48 such as fd12:3456:789a::/48, which holds 65,536 subnets.
Why the global ID is random
RFC 4193 says to generate the 40-bit global ID randomly. Two organizations that pick the same ID would collide as soon as they join their networks through a VPN or a merger. A random 40-bit value makes that very unlikely. Do not choose sequential or memorable values like fd00::/48.
import ipaddress
import secrets
def random_ula_prefix():
global_id = secrets.randbits(40)
value = (0xFD << 120) | (global_id << 80)
return ipaddress.IPv6Network((value, 48))
print(random_ula_prefix()) # for example fd3c:91ab:7e02::/48Scope and routing
ULAs are globally unique in practice, but they are not globally routed. Internet providers filter them out, and routers at your border should do the same. Inside your organization they route like any other unicast address, so they work across many subnets and sites. This differs from link-local addresses, which never leave one link.
import ipaddress
a = ipaddress.ip_address("fd12:3456:789a::1")
print(a.is_private, a.is_global, a.is_link_local)
# True False FalseWhen to use ULAs
- Internal services that must not be reachable from the internet, such as printers or management interfaces.
- Stable addressing that survives a change of ISP, because the ULA prefix does not depend on a provider.
- Lab and test networks.
ULAs usually do not replace global addresses. A host normally has both. It uses the ULA for internal traffic and a global unicast address for the internet.
Common errors
- Using ULAs to reach the internet. There is no route back, so connections fail. Using NAT to fix this brings back the problems IPv6 was meant to remove.
- Treating ULA as a firewall. Not being routed is not the same as being blocked. Keep real filtering rules at the border.
- Reusing one prefix across unrelated networks. Generate a new random prefix for each organization.
- Source address selection surprises. A host with both a ULA and a global address usually prefers the one that matches the destination's scope. Check the result with
ip -6 addr showif traffic takes an unexpected path.
Exercise
A colleague configures the internal network with the prefix fd00:1::/48 because it is easy to remember. What is wrong with this choice, and how would you correct it?
Show answer
The 40-bit global ID is meant to be random so that two networks rarely share a prefix. A memorable value is likely to be picked by others too, so a VPN or a merger could cause overlapping addresses. Generate a random 40-bit global ID, as in the random_ula_prefix function, and use the resulting fd /48 instead.