IPv6 Addresses: Notation, Prefixes, Interface Identifiers and Privacy Addresses
How to read and write 128-bit IPv6 addresses correctly, how prefixes and /64 subnets work, what scopes and zone IDs mean, how hosts build interface identifiers from MAC addresses or random values, and why your machine has several IPv6 addresses at once.
kvi5hnuCode Sprout team member15 min readOn this page
IPv6 was designed in the 1990s to fix IPv4's biggest problem: too few addresses. An IPv6 address is 128 bits long, four times the length of an IPv4 address. That gives 2¹²⁸ addresses, about 340 undecillion (340,282,366,920,938,463,463,374,607,431,768,211,456). The number is so large that IPv6 can afford to spend addresses freely: every LAN gets 2⁶⁴ addresses, and every host can have several.
The bigger addresses change more than their length. IPv6 has a fixed layout for most unicast addresses, a notion of address scope, no broadcast, and several ways for a host to pick its own address. This article covers how IPv6 addresses are written and structured. Special ranges such as fe80::/10 and fc00::/7 are listed in article 11, multicast in article 12, and how hosts configure themselves in articles 31 and 32.
Writing IPv6 addresses
An IPv6 address is written as eight groups of four hexadecimal digits, each group being 16 bits, separated by colons:
2001:0db8:0000:0000:0000:ff00:0042:8329
That's long, so two shortening rules are allowed:
- Leading zeros in a group can be dropped.
0db8becomesdb8,0042becomes42, and0000becomes0. - One run of consecutive all-zero groups can be replaced by
::. The reader knows an address has eight groups, so they can work out how many zeros the::stands for. It can appear only once, otherwise the address would be ambiguous.
Those rules allow many spellings of one address, which makes searching logs and comparing addresses painful. So a later standard (RFC 5952) defines one canonical text form that software should output:
- Drop all leading zeros.
- Use
::for the longest run of zero groups. If two runs are equally long, use it for the first one. - Never use
::for a single zero group: write0. - Write hex digits
atofin lowercase.
Python's ipaddress module outputs the canonical form. Here are several inputs and their canonical (compressed) and full (exploded) forms, from the lab:
2001:0db8:0000:0000:0000:ff00:0042:8329 -> 2001:db8::ff00:42:8329 full: 2001:0db8:0000:0000:0000:ff00:0042:8329
2001:db8:0:0:1:0:0:1 -> 2001:db8::1:0:0:1 full: 2001:0db8:0000:0000:0001:0000:0000:0001
2001:DB8::0001 -> 2001:db8::1 full: 2001:0db8:0000:0000:0000:0000:0000:0001
0:0:0:0:0:0:0:1 -> ::1 full: 0000:0000:0000:0000:0000:0000:0000:0001
:: -> :: full: 0000:0000:0000:0000:0000:0000:0000:0000
2001:db8:0:1:0:0:0:0 -> 2001:db8:0:1:: full: 2001:0db8:0000:0001:0000:0000:0000:0000
Look at the second line: 2001:db8:0:0:1:0:0:1 has two runs of two zero groups, and the first run gets the ::. And in the last line the trailing zeros become :: at the end, so 2001:db8:0:1:: is a valid address that ends in ::.
Here are some invalid forms, each rejected with a clear reason:
2001:db8::1::2 rejected: At most one '::' permitted in '2001:db8::1::2'
2001:db8:12345::1 rejected: At most 4 characters permitted in '12345' in '2001:db8:12345::1'
2001:db8:g::1 rejected: Only hex digits permitted in 'g' in '2001:db8:g::1'
IPv4 inside IPv6 notation
The last 32 bits of an IPv6 address can be written as a dotted quad. The most common case is the IPv4-mapped address, ::ffff: followed by an IPv4 address. Software uses it internally: a program with one IPv6 socket that also accepts IPv4 connections sees an IPv4 client as ::ffff:192.0.2.10. These addresses never appear in packets on the wire.
IPv4-mapped ::ffff:192.0.2.10 = 0000:0000:0000:0000:0000:ffff:192.0.2.10 -> ipv4_mapped: 192.0.2.10
An older form, the IPv4-compatible address (::192.0.2.10, without the ffff), was part of an early transition plan and has been deprecated since 2006. Don't use it.
Addresses in URLs
A colon also separates a host from a port in URLs (web addresses), so an IPv6 address in a URL goes in square brackets:
https://[2001:db8:2::10]:8443/status
The same rule applies in many configuration files and command-line tools that take host:port: [2001:db8::1]:22 is IPv6 port 22, while 2001:db8::1:22 is just a different address.
Prefixes and the /64 subnet
IPv6 uses CIDR prefixes exactly as IPv4 does (article 9), written as address/length: 2001:db8::/32 covers every address whose first 32 bits are 2001:0db8. Longest prefix match picks routes the same way.
What's different is that most IPv6 unicast addresses follow a standard layout. The address splits into a 64-bit network prefix and a 64-bit interface identifier (IID), and the network prefix is usually split again into a site's prefix and a subnet number:

- Every LAN gets a /64. That's 2⁶⁴ addresses per subnet, enough that hosts can pick addresses at random without collisions. Stateless autoconfiguration (hosts building their own address from the router's prefix, article 32) works only with /64 subnets.
- A site gets a prefix of /48 to /60 from its provider, so it can number many /64 subnets: a /48 holds 65,536 of them, a /56 holds 256. Home broadband connections usually get a /56 or /60.
- Point-to-point links between routers usually use /127, the IPv6 version of IPv4's /31, though many networks still reserve a whole /64 for each link and configure the /127 inside it.
Scopes and many addresses per interface
Every IPv6 address has a scope, the part of the network where it's valid:
- Interface-local (also called node-local): only within one host. This scope is used mainly by multicast (
ff01::/16). The loopback address::1also never leaves the host (Linux shows it asscope host), although the addressing standard formally gives it link-local scope. - Link-local: only on one link. Every IPv6 interface automatically gets one from
fe80::/10(in practice alwaysfe80::/64), even with no router or DHCP server (the Dynamic Host Configuration Protocol server that hands out addresses). IPv6 needs these addresses to work at all: neighbor discovery (finding the hardware addresses of hosts on the link) and router advertisements (messages in which routers announce themselves and the prefix to use) are sent from them. - Global: valid across the Internet.
There was once a site-local scope (fec0::/10), but it was deprecated in 2004 because nobody could agree where a "site" ended and the addresses leaked between sites. Unique local addresses (article 11) replaced it.
Because of scopes and autoconfiguration, an IPv6 interface normally has several addresses at once: at least one link-local address, and typically one or more global addresses per prefix the router advertises. You'll see this in the lab output below. Hosts choose which address to use as the source of each connection with a standard set of rules (article 28).
Zone IDs for link-local addresses
A link-local address is only meaningful on one link, and a host with two interfaces has fe80::/64 on both. So when you use a link-local destination, you must also say which interface you mean, with a zone ID after a %.
In the lab, host h has two interfaces, eth0 and eth1, both connected to router r. Both have a route for fe80::/64. The third line is the default route, learned from the router's advertisement (proto ra). It points at the router's link-local address and expires unless the router keeps re-advertising:
fe80::/64 dev eth0 proto kernel metric 256 pref medium
fe80::/64 dev eth1 proto kernel metric 256 pref medium
default via fe80::ff:fe00:1 dev eth0 proto ra metric 1024 expires 11sec hoplimit 64 pref medium
fe80::ff:fe00:1 is the router's link-local address on the link attached to h's eth0. With %eth0 it answers. The same address with %eth1 gets no answer, because on that link nobody has it:
PING fe80::ff:fe00:1%eth0 (fe80::ff:fe00:1%eth0) 56 data bytes
64 bytes from fe80::ff:fe00:1%eth0: icmp_seq=1 ttl=64 time=0.162 ms
PING fe80::ff:fe00:1%eth1 (fe80::ff:fe00:1%eth1) 56 data bytes
1 packets transmitted, 0 received, 100% packet loss, time 0ms
Without a zone ID, Linux happened to pick the first matching route, eth0, so the ping worked, but only by luck:
PING fe80::ff:fe00:1 (fe80::ff:fe00:1) 56 data bytes
64 bytes from fe80::ff:fe00:1%eth0: icmp_seq=1 ttl=64 time=0.059 ms
Interface identifiers
The low 64 bits, the interface identifier, must be unique on the link. There are several ways a host gets one:
- Modified EUI-64 (EUI stands for Extended Unique Identifier), derived from the interface's MAC address, the hardware address of its network card (article 14). This was the original method.
- Stable, opaque IIDs: a hash of the prefix, the interface and a secret, which looks random but stays the same on the same network (RFC 7217). This is the recommended default today.
- Temporary addresses: random IIDs that change regularly, for privacy (RFC 8981).
- Assigned by DHCPv6 (article 31) or configured by hand, often memorable values like
::1for a router or::53for a DNS server.
Modified EUI-64
A MAC address is 48 bits (an EUI-48, in the terms of the IEEE, the standards body for Ethernet and Wi-Fi), made of a 24-bit Organizationally Unique Identifier (OUI) for the manufacturer and 24 bits the manufacturer assigns. To make a 64-bit IID from it:
- Insert the 16 bits
ff:fein the middle, between the OUI and the rest. This gives an EUI-64. - Invert bit 0x02 of the first byte, the "universal/local" bit. In a MAC address, 0 in that bit means "universally administered" (assigned by the manufacturer). Inverting it means a manually configured IID such as
::1comes out as "local", which keeps typed-in IIDs short. For the first byte00that's00000000→00000010, which is02. If the byte had been02already (a locally administered MAC), it would flip to00.
Here is that procedure for 00:00:5e:00:53:01, a MAC address reserved for documentation, computed step by step in the lab. The 64-bit intermediate values are written with hyphens, the IEEE's own notation, so they can't be mistaken for IPv6 addresses:
MAC (EUI-48) 00:00:5e:00:53:01
insert ff-fe (EUI-64) 00-00-5e-ff-fe-00-53-01
flip bit 0x02 (u bit) 02-00-5e-ff-fe-00-53-01
interface identifier 0200:5eff:fe00:5301
link-local address fe80::200:5eff:fe00:5301

The diagram shows the same four steps. The Linux kernel does exactly this when an interface with that MAC address comes up in EUI-64 mode:
11: eth0@if12: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link-netns r
inet6 fe80::200:5eff:fe00:5301/64 scope link proto kernel_ll
valid_lft forever preferred_lft forever
When the router on the link advertises a prefix, 2001:db8:1::/64 here, the host forms a global address the same way, with the same IID after the prefix. mngtmpaddr marks it as the address from which temporary addresses are made, and dynamic means it has limited lifetimes, which come from the router advertisement (article 32). valid_lft is how long the address may be used at all and preferred_lft how long it's used for new connections, here about a day and four hours:
11: eth0@if12: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link-netns r
inet6 2001:db8:1:0:200:5eff:fe00:5301/64 scope global dynamic mngtmpaddr proto kernel_ra
valid_lft 86399sec preferred_lft 14399sec
Why EUI-64 fell out of favor: privacy
An EUI-64 IID is the same on every network the device joins. A laptop that's at home in the morning, at a café at noon and at the office in the afternoon uses three different prefixes but the same IID, so any server it talks to can follow it around. It also reveals the manufacturer, through the OUI. Since 2017, the IETF has recommended that hosts not use EUI-64 for autoconfigured addresses, and use stable opaque IIDs instead (RFC 8064).
Two mechanisms replace it:
- Stable opaque IIDs (RFC 7217, called
stable-privacyon Linux). The IID is a hash of the prefix, the interface, a host secret and some other values. It stays the same as long as the host stays on the same network, so server allow-lists and logs still work, but it's different on every network, so it can't be used to track the host across networks. - Temporary addresses (RFC 8981, previously RFC 4941). The host also creates random-IID addresses that it uses as the source of outgoing connections, and replaces them regularly, typically every day. Old ones stay valid for a while so existing connections can finish.
Here the lab host switches to stable-privacy IIDs and enables temporary addresses (use_tempaddr=2 means "create them and prefer them for outgoing traffic"). After the interface comes back up, it has three addresses:
11: eth0@if12: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link-netns r
inet6 2001:db8:1:0:edb2:6e79:caf5:cfa9/64 scope global temporary dynamic
valid_lft 86398sec preferred_lft 14398sec
inet6 2001:db8:1:0:ea68:87dc:997d:5fe5/64 scope global dynamic mngtmpaddr stable-privacy proto kernel_ra
valid_lft 86398sec preferred_lft 14398sec
inet6 fe80::f87b:c2:cebc:1333/64 scope link stable-privacy proto kernel_ll
valid_lft forever preferred_lft forever
fe80::f87b:...and2001:db8:1:0:ea68:..., both markedstable-privacy, are the stable opaque addresses. Neither contains the MAC.2001:db8:1:0:edb2:..., markedtemporary, is the temporary address. Its lifetimes are capped by the prefix's lifetimes from the router advertisement.
And the temporary address is the one the kernel picks as the source for a new connection, as the src field shows:
2001:db8:2::10 from :: via fe80::ff:fe00:1 dev eth0 proto ra src 2001:db8:1:0:edb2:6e79:caf5:cfa9 metric 1024 hoplimit 64 pref medium
Common questions
Can I write an IPv6 address in uppercase?
You can type it that way and every parser accepts it, but software should output lowercase (RFC 5952), and logs are easier to search if everyone does.
Why can :: appear only once?
Because the reader must work out how many zero groups it replaces. In 2001::1::2 there's no way to know whether the first :: stands for one zero group and the second for four, or the other way round.
Is 2001:db8:: the same as 2001:db8::0?
Yes. Both are 2001:0db8:0000:0000:0000:0000:0000:0000. The canonical form is 2001:db8::.
Do I need a /64 for a LAN even if it has three hosts?
Yes. Stateless autoconfiguration and several other mechanisms assume 64-bit IIDs, and the address space is designed for it. Using longer prefixes on LANs breaks autoconfiguration and gains nothing.
Why does my computer have so many IPv6 addresses?
A link-local address on each interface, a stable address per advertised prefix, a temporary address per prefix (plus older ones still finishing their lifetimes), and possibly DHCPv6 and unique local addresses. Five or more per interface is normal.
Do temporary addresses make me anonymous?
No. They stop servers from linking your connections by IID across networks and over long periods, but your prefix still identifies your network, often your home, and cookies and logins identify you regardless.
Does IPv6 have a broadcast address?
No. IPv6 uses multicast instead, for example ff02::1 for all nodes on a link (article 12). There's no all-ones host address, so every address in a subnet, including the one ending in ffff:ffff:ffff:ffff, can be assigned. The address with an all-zero IID is reserved as the subnet-router anycast address, which reaches any one of the subnet's routers (article 12 explains anycast).
Summary
- An IPv6 address is 128 bits, written as eight 16-bit hex groups. Leading zeros can be dropped and one run of zero groups can become
::. The canonical form is lowercase, with::for the longest (then first) run of two or more zero groups. ::ffff:a.b.c.dis an IPv4-mapped address, used inside software. In URLs andhost:portsyntax, IPv6 addresses go in brackets.- Most unicast addresses are a 64-bit network prefix plus a 64-bit interface identifier. Every LAN gets a /64, and sites get /48 to /60.
- Addresses have a scope: interface-local (inside one host, where
::1also stays), link-local (fe80::/64, on every interface) or global. Link-local destinations need a zone ID such as%eth0. - Modified EUI-64 builds an IID from the MAC by inserting
ff:feand flipping bit 0x02. It exposes the MAC and lets hosts be tracked, so stable opaque IIDs (RFC 7217) are now recommended, and temporary addresses (RFC 8981) are used as the source of outgoing connections. - An IPv6 interface normally has several addresses at once.
Practice questions
1. Write 2001:0db8:0000:0042:0000:0000:0000:0001 in canonical form.
Answer
Drop leading zeros: 2001:db8:0:42:0:0:0:1. The longest zero run is the three groups before the 1, so it becomes 2001:db8:0:42::1.
2. Expand 2001:db8::8:800:200c:417a to all eight groups.
Answer
The address shows six groups, so :: stands for two zero groups: 2001:0db8:0000:0000:0008:0800:200c:417a.
3. Which of these is canonical: 2001:db8:0:0:1::1, 2001:db8::1:0:0:1, 2001:DB8::1:0:0:1?
Answer
2001:db8::1:0:0:1. The first one uses :: for a shorter run when an equal run comes earlier (both runs are two groups, so the first run gets ::), and the third uses uppercase.
4. A device's MAC address is 00:00:5e:00:53:2a. What is its modified EUI-64 link-local address?
Answer
Insert ff-fe: 00-00-5e-ff-fe-00-53-2a. Flip bit 0x02 of the first byte: 02-00-5e-ff-fe-00-53-2a. So the address is fe80::200:5eff:fe00:532a.
5. Why do you need %eth0 in ping fe80::1%eth0 but not in ping 2001:db8::1?
Answer
Link-local addresses are valid only on one link, and every interface has the same fe80::/64 prefix, so the address alone doesn't say which link to use. A global address is unique everywhere, so the routing table can pick the interface.
6. How many /64 subnets does a site with a /56 get?
Answer
64 − 56 = 8 subnet bits, so 2⁸ = 256 subnets.
7. A server's access log shows a client address that changes every day, but the first 64 bits stay the same. What's going on?
Answer
The client is using temporary addresses (RFC 8981): its network prefix (the first 64 bits) stays the same, while its host creates a new random interface identifier regularly and uses it as the source of new connections.
Previous: CIDR and Route Aggregation: Prefixes and Longest Match
Next: Special-Use Addresses: Private, Loopback, Link-Local, Documentation and Shared Ranges

More in TCP/IP Course
Quiz: TCP/IP Delicate Details
Twenty-five questions on the details that catch out experienced engineers: sequence numbers for SYN and FIN, TIME_WAIT versus tcp_fin_timeout, Karn's algorithm, socket buffer doubling, even and odd ephemeral ports, IPv6 checksums and fragmentation, negative DNS caching, and capture filter traps.
Quiz: TCP/IP Interview Questions
Thirty-three networking questions of the kind asked in developer, SRE and network engineering interviews: what happens when you load a URL, TCP versus UDP, handshakes, closing and TIME_WAIT, subnetting, NAT, DNS, MTU problems, congestion, TLS and QUIC, and debugging slow or failing connections.
Quiz: TCP/IP Course Final Exam (All Parts)
The final exam for the TCP/IP course: thirty questions across all fourteen parts, from packets and addressing through Ethernet, ARP, IP, DHCP, NAT, ICMP, UDP, DNS, TCP connections, reliability, congestion control, security, QUIC and troubleshooting.
Quiz: Modern Transports and Troubleshooting (TCP/IP Part 14)
Review modern transports and troubleshooting: QUIC packets, handshakes, 0-RTT, streams and connection migration, HTTP/3, Multipath TCP, SCTP multihoming, and a layered method for diagnosing real network faults.
Discussion
Sign in to ask a question or share what you learned.