Sub topic 6
Global unicast addresses
This chapter assumes you know how IPv6 addresses are written and compressed, and how prefix length notation works. It also assumes you know the address types from the previous chapter.
What a global unicast address is
A global unicast address (GUA) identifies one interface and is routable on the public internet. It is the IPv6 counterpart of a public IPv4 address. GUAs come from the block 2000::/3. The first three bits are 001, so the block runs from 2000:: to 3fff:ffff:ffff:ffff:ffff:ffff:ffff:ffff.
Unlike most IPv4 networks, IPv6 gives each device its own globally unique address, so NAT is not needed to conserve addresses.
How the address is divided
A typical GUA has three parts:
| Part | Typical size | Example |
|---|---|---|
| Global routing prefix | 48 bits | `2001:db8:abcd` |
| Subnet ID | 16 bits | `0012` |
| Interface ID | 64 bits | `0211:22ff:fe33:4455` |
The full address is 2001:db8:abcd:12:211:22ff:fe33:4455. The first 64 bits (routing prefix plus subnet ID) name the subnet. The last 64 bits name the interface within it.
Where the prefixes come from
Addresses are delegated in a hierarchy. Regional internet registries assign large blocks to ISPs, and ISPs assign smaller blocks to customers.
ISPs commonly give a site a /48, or a /56 for home users. The site then cuts that prefix into /64 subnets. Because the allocation comes from your provider, changing ISPs usually means renumbering.
Checking whether an address is a GUA
You can test membership in 2000::/3 with Python's ipaddress module:
import ipaddress
gua = ipaddress.ip_network("2000::/3")
for text in ["2001:db8::1", "2606:4700:4700::1111", "fe80::1", "fd12:3456:789a::1", "ff02::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
# ff02::1 FalseCommon mistakes
- Treating the
/64boundary as optional. Features such as SLAAC expect a 64-bit interface ID, so use/64for ordinary LAN subnets. - Confusing the subnet ID with the interface ID when reading a compressed address. Expand the address first, then count 16-bit groups.
- Assuming a GUA is exposed by default. A global address makes a host reachable in principle, so you still need firewall rules.
Exercise
A site has the prefix 2001:db8:abcd::/48. A host has the address 2001:db8:abcd:12:211:22ff:fe33:4455. What is its subnet ID, and what is the /64 subnet prefix it belongs to?
Show answer
With a /48 site prefix, the fourth group is the subnet ID, which is 0012 (written 12 after dropping leading zeros). The /64 subnet prefix is 2001:db8:abcd:12::/64. The remaining 64 bits, 211:22ff:fe33:4455, are the interface ID.