Unique Local Addresses and multiple prefixes
Generate a ULA /48 with the RFC 4193 pseudo-random Global ID method and explain why it must not be chosen by hand. Decide when ULA is appropriate, and when it is not a substitute for global addresses. Predict source and destination address selection when hosts have both ULA and GUA addresses, using the RFC 6724 policy table. Explain first-hop router selection in multi-prefix networks (RFC 8028).
Take the quiz · pass mark 70% · 9 questions
Explanation
Level 1 introduced Unique Local Addresses (ULAs) as the IPv6 range for local use (L1.03). This lesson covers how to create a ULA prefix correctly, where ULAs belong in a plan, and what happens when a host has more than one prefix, which in IPv6 is normal rather than an exception.
The ULA format (RFC 4193)
ULAs come from fc00::/7. The eighth bit, L, must be 1 for locally assigned prefixes, so in practice every ULA prefix starts with fd. (fc00::/8, with L = 0, is reserved for a possible future definition and is not used.)
| Bits | 7 | 1 | 40 | 16 | 64 |
|---|---|---|---|---|---|
| Field | Prefix 1111 110 | L = 1 | Global ID | Subnet ID | Interface ID |
The first 48 bits (fd + Global ID) form your site's ULA /48. The 16-bit Subnet ID gives 65,536 /64 subnets, exactly like a GUA /48.
Generating the Global ID
The Global ID must be pseudo-random. That is what makes ULAs "unique": if two organisations merge, connect over a VPN, or join a partner network, their ULA prefixes are very unlikely to collide. Choosing fd00::/48 or fd12:3456:789a::/48 by hand defeats the purpose. Those are exactly the prefixes everybody else picks.
RFC 4193 (section 3.2.2) gives a sample algorithm:
- Get the current time of day in 64-bit NTP format.
- Get an EUI-64 identifier from the system (or build one from a MAC address, as in L1.06).
- Concatenate time and EUI-64 to create a key.
- Compute the SHA-1 digest of the key (160 bits).
- Use the least significant 40 bits as the Global ID.
- Put
fdin front: the result is the ULA /48.
The chance of a collision between N interconnected random Global IDs is about 1 − exp(−N² / 2^41). RFC 4193 lists 4.54 × 10^-11 for 10 connected networks and 4.54 × 10^-7 for 1,000.
The course ULA
For examples, this course uses a ULA generated with the algorithm and fixed inputs, so that you can reproduce it:
- NTP time
0xeb5d2c8000000000(17 February 2025, 03:33:20 UTC) - MAC
52:54:00:12:34:56→ EUI-645054:00ff:fe12:3456 - SHA-1 of the 16-byte key
eb5d2c8000000000505400fffe123456ends in…f1a86126b6 - ULA /48:
fdf1:a861:26b6::/48
This prefix is invented for the course. In the lab you generate your own.
When ULA is appropriate
ULAs are routable inside a site or between cooperating sites, but must never be announced to or accepted from the Internet. Good uses:
- Stable internal addressing that survives ISP changes, for example for internal DNS servers, printers, or management, when the GUA prefix is dynamic (a home with a changing delegated prefix).
- Isolated networks that will never reach the Internet: lab networks, out-of-band management, and some industrial systems.
- Internal services in addition to GUA, so that internal configuration does not have to be renumbered.
ULA is not a replacement for global addresses. A network that numbers hosts only with ULA and then uses NAT66 to reach the Internet recreates the IPv4 NAT problems that IPv6 removes (L1.01). RFC 6177 makes sure end sites get enough global space that they are never forced into address translation.
Hosts with several prefixes
An IPv6 host commonly has several addresses on one interface: a link-local address, one or more GUAs (stable and temporary), maybe a ULA, and during renumbering (L2.08) addresses from both the old and new prefix. Two decisions follow for every connection:
- Destination selection: if a name resolves to several addresses, which one to try first.
- Source selection: which of the host's own addresses to use as the source.
Both are governed by RFC 6724 and its policy table:
| Prefix | Precedence | Label |
|---|---|---|
::1/128 | 50 | 0 |
::/0 | 40 | 1 |
::ffff:0:0/96 (IPv4) | 35 | 4 |
2002::/16 | 30 | 2 |
2001::/32 | 5 | 5 |
fc00::/7 (ULA) | 3 | 13 |
::/96 | 1 | 3 |
fec0::/10 | 1 | 11 |
3ffe::/16 | 1 | 12 |
Key consequences:
- Destination: GUA destinations (precedence 40) are preferred over IPv4 (35), and IPv4 is preferred over ULA (3). A dual-stack host that gets both a ULA and an IPv4 address for a name will try IPv4 first. This is deliberate: an arbitrary ULA may not be reachable.
- Source: Rule 6 ("prefer matching label") pairs a GUA destination (label 1) with a GUA source and a ULA destination (label 13) with a ULA source. Rule 8 (longest matching prefix) breaks remaining ties.
- Changing the policy: RFC 6724 section 10.6 shows how to add a site-specific entry such as
fdf1:a861:26b6::/48with precedence 45 and its own label, so that your own ULAs are preferred over GUAs inside the site. On Linux, glibc reads destination-ordering changes from/etc/gai.conf, and the kernel's source-selection label table is shown and changed withip addrlabel.
Multiple prefixes and multiple routers (RFC 8028)
A small site can be multihomed with PA space from two ISPs: router A advertises prefix A, router B advertises prefix B, and hosts form addresses in both. Each ISP applies ingress filtering (BCP 38) and drops packets with the other ISP's source prefix. If a host sends a packet with source A through router B, it is dropped.
RFC 8028 fixes this on the host side:
- A host should select default routers per prefix, extending the default router selection of RFC 4861 (section 6.3.6). A router that advertised the prefix of the chosen source address should be preferred over routers that did not, regardless of default router preference (RFC 4191).
- Hosts that do this should also implement RFC 6724 Rule 5.5: prefer a source address from a prefix advertised by the next hop that will be used.
Drawing diagram…
Not every operating system implements RFC 8028 fully, which is one reason many sites prefer PI space and BGP (L2.02) or a single router for multihoming.
Worked examples
Example 1: Generate a ULA
Using the fixed inputs above, SHA-1 gives 105d6496c781ef51219ed50ede7370f1a86126b6. The last 40 bits (10 hex digits) are f1a86126b6. With fd in front, written in groups: fdf1:a861:26b6::/48.
Example 2: A ULA subnet
Subnet ID 0x0010 (to match the GUA VLAN numbering) in the course ULA is fdf1:a861:26b6:10::/64. A host with interface ID ::25 has fdf1:a861:26b6:10::25.
Example 3: The size of the ULA space
There are 2^40 = 1,099,511,627,776 possible Global IDs, so a random choice almost never collides for a few hundred connected sites.
Example 4: Destination ordering
A host has 2001:db8:3000:10::25, fdf1:a861:26b6:10::25 and 192.0.2.25. The name intranet resolves to fdf1:a861:26b6:20::80 and 192.0.2.80. Default policy: IPv4 has precedence 35 and ULA has 3, so 192.0.2.80 is tried first. After adding fdf1:a861:26b6::/48 with precedence 45 (RFC 6724 section 10.6), the ULA is tried first, with source fdf1:a861:26b6:10::25 (matching label).
Example 5: Source for a GUA destination
The same host connects to 2001:db8:f000::80. The destination has label 1. Only the GUA source has label 1, so Rule 6 picks 2001:db8:3000:10::25.
Lab
Goal: Generate your own ULA, give a host ULA and GUA addresses, and observe and change address selection.
You need: Linux with root, Python 3, and the namespace skills from L1.03 and L2.03.
Step 1: Generate your ULA
Write ula.py that implements RFC 4193 section 3.2.2: read the current time, convert it to 64-bit NTP format (seconds since 1900 in the top 32 bits, fraction in the bottom 32), build an EUI-64 from one of your MAC addresses, hash with hashlib.sha1, and print the /48. Check your code by reproducing fdf1:a861:26b6::/48 from the fixed inputs in this lesson. Then generate your own ULA and record it.
Step 2: Build the network
Create namespaces h1 (client) and srv (server) on one link. Give each a GUA from 2001:db8:3000:10::/64 and a ULA from <your-ula>:10::/64, plus an IPv4 address from 192.0.2.0/24:
sudo ip -n h1 addr add 2001:db8:3000:10::25/64 dev veth-h
sudo ip -n h1 addr add <your-ula>:10::25/64 dev veth-h
sudo ip -n h1 addr add 192.0.2.25/24 dev veth-h
# srv: ::80 and 192.0.2.80 in the same prefixes
Step 3: Source selection
sudo ip netns exec h1 ip -6 route get 2001:db8:3000:10::80
sudo ip netns exec h1 ip -6 route get <your-ula>:10::80
sudo ip netns exec h1 ip addrlabel list
Record the source address chosen for each destination and explain it with Rule 6 and the label table.
Step 4: Destination ordering
Add intranet to /etc/hosts with the server's ULA and IPv4 addresses (not the GUA). Run getent ahosts intranet in h1 and record the order. Then add precedence <your-ula>/48 45 to /etc/gai.conf (keep a backup), run the command again, and compare. Remove the change afterwards.
Step 5: Think about RFC 8028
Without building it, sketch how you would test RFC 8028 behaviour with two routers advertising two different GUA prefixes, and what you would capture to prove that the host picks the right router.
What to submit
ula.py, your ULA, the outputs of steps 3 and 4 before and after the change, and your step 5 sketch.
Summary
- ULA =
fd+ 40-bit pseudo-random Global ID + 16-bit Subnet ID. Generate it with the RFC 4193 method. Never pick it by hand. - Use ULA for stable or isolated internal addressing alongside GUA, not as an excuse for NAT66.
- RFC 6724 default policy: GUA (40) > IPv4 (35) > ULA (3) for destinations. Matching labels pair ULA with ULA and GUA with GUA for sources. A site policy entry can raise your own ULA.
- With several prefixes from several routers, hosts should send via the router that advertised the source prefix (RFC 8028) and prefer sources advertised by the next hop (Rule 5.5).
- Next lesson (L2.07): reverse DNS for all these prefixes.
Quiz imported · 9 questions · pass mark 70%. Lab questions are not auto-marked.