关于有状态/无状态IPv6地址配置与临时/非临时IPv6地址的处理逻辑及相关疑问
Great question—let's break down the IPv6 address configuration logic you've observed, along with those temporary addresses showing up on your devices.
Core Configuration Basics (RA Flags & Address Types)
First, router advertisement (RA) ICMPv6 packets are the backbone of IPv6 auto-configuration, with three key flags controlling behavior:
- A (Autonomous) flag: When set to 1, enables SLAAC (Stateless Address Autoconfiguration). Devices take the 64-bit prefix from the RA, then generate their own 64-bit interface ID (this doesn't have to be EUI-64—many modern systems use random algorithms now) to form a global unicast IPv6 address. This is a stable, long-lived address tied to the device's configuration.
- M (Managed) flag: When set to 1, triggers stateful DHCPv6. The device will reach out to a DHCPv6 server to request a centrally allocated IPv6 address.
- O (Other) flag: When set to 1, tells the device to use DHCPv6 for additional network settings (like DNS servers), even if it's using SLAAC for the address itself.
When all three flags (A, M, O) are set to 1, your device will do both: create a stateless SLAAC address and request a stateful address from the DHCPv6 server. That's one scenario where you might see multiple global unicast addresses with the same prefix.
Temporary IPv6 Addresses Explained
The "temporary" address you're spotting comes from IPv6 Privacy Extensions, a feature enabled by default on Linux, macOS, and Windows. Here's how it works:
- Alongside the stable SLAAC address, the system generates a second address using the same prefix but a random, ephemeral 64-bit interface ID.
- This temporary address is used for outgoing connections (like browsing the web) and rotates regularly (usually every few hours or days). Its purpose is to prevent tracking of your device via a fixed IPv6 address.
- The stable address remains for use cases where a consistent identifier is needed (e.g., incoming connections, device-to-device communication on the local network).
When you run commands like ip addr (Linux), ifconfig (macOS), or ipconfig (Windows), you'll see both the stable SLAAC address and this rotating temporary address listed—this is the pair of same-prefix global unicast addresses you're noticing.
备注:内容来源于stack exchange,提问作者Yan

