Sub topic 6
Global unicast addresses
This chapter assumes you know how to read and compress IPv6 addresses, how prefix-length notation works, and the difference between unicast, multicast, and anycast. It also assumes you know the basic role of routers and default gateways.
What a global unicast address is
A global unicast address (GUA) identifies one interface and is routable on the public IPv6 internet. It is the closest IPv6 equivalent of a public IPv4 address. Unlike IPv4, nearly every device on an IPv6 network normally has one, because there is no shortage that forces address sharing through NAT.
The current GUA range is 2000::/3. The first three bits of every address in it are 001, so the first hex digit is 2 or 3. That makes the range 2000:: through 3fff:ffff:ffff:ffff:ffff:ffff:ffff:ffff. It is one eighth of the whole address space. The other seven eighths are reserved for other uses or held back for the future.
Two points are easy to get wrong:
- "Global" describes the scope of the address, not whether a host can be reached. A firewall can still block inbound traffic to a GUA.
- A GUA is not always the address that is used. A host usually also has a link-local address, and it may have unique local addresses. It chooses among them by destination and scope.
The hierarchy behind the prefix
GUAs are handed out in layers. Each layer receives a block and splits it among the layers below. This keeps the global routing table small, because an ISP can advertise one short prefix instead of thousands of customer prefixes.
The lengths below are typical practice, not fixed protocol rules.
| Level | Typical length | Who decides |
|---|---|---|
| Global block | /3 | IANA |
| Regional registry (RIR) | about /12 | IANA allocates |
| ISP or large organization | /32 or longer | RIR allocates |
| End site | /48, or /56 for many homes | ISP assigns |
| Subnet | /64 | Site administrator |
Regional registries hold blocks such as 2400::/12 (APNIC), 2600::/12 (ARIN), and 2a00::/12 (RIPE NCC). If you see an address starting 2a00:, the block was allocated by RIPE NCC to a provider in its service region. The address does not tell you where the host physically is.
Three fields: routing prefix, subnet ID, interface ID
For a normal GUA on a LAN, read the 128 bits as three fields:
- The global routing prefix, usually 48 bits, assigned by the provider.
- The subnet ID, usually 16 bits, chosen by you.
- The interface identifier (IID), 64 bits, which identifies the host on that subnet.
The 64-bit boundary matters. SLAAC, which a later chapter covers, assumes a /64 subnet. Using a /80 or /120 on a normal LAN breaks autoconfiguration and many features that depend on it. Point-to-point router links are the usual exception, and /127 is used there on purpose.
The following script splits an address into those fields with integer arithmetic.
import ipaddress
addr = ipaddress.IPv6Address("2001:db8:abcd:12:21a:2bff:fe3c:4d5e")
n = int(addr)
site = ipaddress.IPv6Network((n >> 80 << 80, 48))
subnet_id = (n >> 64) & 0xFFFF
iid = n & (2**64 - 1)
print(site) # 2001:db8:abcd::/48
print(hex(subnet_id)) # 0x12
print(f"{iid:016x}") # 021a2bfffe3c4d5eShifting right by 80 and back left clears the lower 80 bits, which leaves the /48 prefix. The subnet ID is bits 48 to 63 and the IID is the low 64 bits.
Recognizing a GUA
To test whether an address is in the GUA range, check membership in 2000::/3. Do not just look at the first digit by eye, because 2002:: and 3ffe:: behave differently from ordinary provider space.
import ipaddress
gua = ipaddress.ip_network("2000::/3")
print(gua.network_address, gua.broadcast_address)
print(2 ** (64 - gua.prefixlen)) # number of /64 subnets: 2305843009213693952
for text in ["2001:db8::1", "2606:4700:4700::1111", "fe80::1",
"fd12:3456:789a::1", "::1"]:
print(text, ipaddress.ip_address(text) in gua)
# 2001:db8::1 True
# 2606:4700:4700::1111 True
# fe80::1 False
# fd12:3456:789a::1 False
# ::1 FalseThe first line prints 2000:: and 3fff:ffff:ffff:ffff:ffff:ffff:ffff:ffff. IPv6 has no broadcast, so the attribute name broadcast_address is only the last address of the range. The count is 2^61, about 2.3 quintillion /64 subnets in 2000::/3 alone.
Special ranges inside 2000::/3
Some blocks inside 2000::/3 are not ordinary provider space:
| Prefix | Purpose |
|---|---|
| `2001:db8::/32` | Documentation examples. Never routed. |
| `2002::/16` | 6to4 transition addresses. Deprecated. |
| `2001::/32` | Teredo tunneling. Legacy. |
Python's is_global returns False for 2001:db8::1, because the documentation block is treated as non-global. Use in 2000::/3 when you only care about the format, and use is_global when you need to rule out reserved blocks too. The two checks answer different questions.
Provider-assigned and provider-independent space
Most sites use provider-assigned (PA) space, which is a slice of the ISP's block. It aggregates well, but changing ISPs means renumbering every host. Large organizations can request provider-independent (PI) space from a registry and keep it across providers. In exchange they must get it announced in global routing, which usually means running BGP, and they pay registry fees.
Renumbering is much less painful than in IPv4 if you design for it. Hosts that get addresses by SLAAC pick up a new prefix from Router Advertisements. The old prefix can be deprecated gradually while its lifetimes run out. Hard-coded GUAs in configuration files, firewall rules, and DNS records are what make renumbering hard. Prefer DNS names, and keep prefixes in one place in your configuration.
Common errors
- Using
/48where you were given/56. Many home ISPs delegate a /56, which gives 256 subnets, not 65,536. Check the delegated prefix before you plan. - Treating a GUA as private. A GUA is reachable from anywhere unless something blocks it. Keep a default-deny inbound firewall policy on the border router.
- Subnetting below /64 on a LAN. This breaks SLAAC and can strain neighbor caches.
- Assuming the address reveals the host's location. The prefix identifies the provider's allocation, not the building.
Checking addresses on a host
On Linux, ip -6 addr show scope global lists only the GUAs on the host, with their prefix lengths and lifetimes. An address marked deprecated is still valid for existing connections, but the host will not choose it for new ones. An address marked temporary is a privacy address, which the interface identifiers chapter covers.
ip -6 addr show scope global
ip -6 route show defaultThe second command shows the default route and the router's link-local next hop. Finding a link-local address as the gateway is normal, and it is the usual way IPv6 routes work.
Exercise
A provider delegates 2001:db8:5a00::/56 to your home. How many /64 subnets can you create, and what is the prefix of the subnet whose subnet ID bits are 0x03 in the last byte of the delegated range?
Show answer
A /56 leaves 64 - 56 = 8 bits for the subnet ID, so you can create 2^8 = 256 /64 subnets. With subnet ID 0x03, the fourth group becomes 5a03, so the subnet is 2001:db8:5a00:3::/64 with the group written as 5a03. The correct prefix is 2001:db8:5a03::/64.
Exercise
Is fd12:3456:789a::1 a global unicast address? Explain using the prefix.
Show answer
No. It begins with fd, which falls in fc00::/7 (unique local), not in 2000::/3. GUAs begin with the bits 001, which means the first hex digit is 2 or 3.