Stateless Address Autoconfiguration is a technique where individual nodes in a network can generate their own unique IP address, based on a “network address” which the router will send out, and a unique part generated from the hosts’ MAC address.
Here’s how it works. The router sends out a “router advertisement” or RA, which contains the first 64bit of an IPv6 address. This value is defined on the router, by the network administrator. The host itself will use its own MAC Address, add some magic, and use it as the last 64 bit of the IPv6 address. Combine those, and you have a unique IPv6 network address.
Take the following example: the router will “advertise” the first 64 bits of the 128bit IPv6 address as 2001:0af2:0005:0001.
The MAC address of the node’s network card is 00:0A:95:A4:40:10, which in turn consists of 2 distinguishable parts. The first 24 bits (or the first 3 ‘blocks’ in the MAC address) are the OUI or Organizationally Unique Identifier. In this example, this would be 000A95. This is the OUI that is assigned by IEEE (Institute of Electrical and Electronic Engineers), and is guaranteed to be unique worldwide. The second part of the MAC address, or A44010 is a unique part that the owner of the OUI can assign.
The first part of the MAC address is guaranteed to be unique by IEEE, the second part is guaranteed to be unique by the owner the of OUI (=the company which was assigned that specific OUI; ie: Apple, Xerox, HP, …).
The MAC address, however, has a so called “universal / local bit”. A specific bit (0/1) to indicate whether the MAC address is globally unique (provided by the hardware supplier), or not (it might be altered afterwards) and whether the MAC address is a multicast address, or a unicast address.
If a MAC address is not available, the “universal / local bit” is set to one, to indicate that the MAC address isn’t globally unique, and can’t be used universally. The end result – a combination of the 64 bit router-supplied prefix, and the MAC address – will form a Modified EUI-64 instead of a regular EUI-64 (because the “u/l bit” was flipped).
For those keeping count, you will have noticed that a MAC address does not contain 64 bits, and in itself would not be sufficient to be used as the last 64 bits of the IPv6 address. The 48bit MAC address should first be turned into a 64bit EUI-64, by adding the hexademical value FFEE in between the OUI (first 6 bits) and the owner-assigned bits (last 6 bits).
00:0A:95:A4:40:10 is the full MAC address
000A95 is the OUI
A44010 is the organization-assigned value
000A95FFEEA44010 is the 64-bit EUI-64
The end result, 000A95FFEEA44010, is EUI-64 which can be used as the last 64 bits of an IPv6 address.
In total, our IPv6 address could be as follows.
2001:0af2:0005:0001 are the first 64 bits advertised by our router
000a:95ff:eea4:4010 are the last 64 bits, made from the MAC address to a EUI-64
2001:0af2:0005:0001:000a:95ff:eea4:4010 is the logical combination of both
2001:af2:5:1:a:95ff:eea4:4010 is the shortened version, with leading zeros removed
If there are multiple routers, each handing out different address prefixes, the host will create a IPv6 address for each of those prefixes. A router can even announce a new prefix, and the connected clients will generate a new IP based on this new prefix. To keep existing connections alive, the previous IP address isn’t deleted right away, but marked as “deprecated” first.
Using Stateless Autoconfiguration can be a good way to assign the same IP to the same host, providing the MAC address of that host doesn’t change. Should a NIC (Network Interface Card) be replaced, removed or added, the MAC address will change, and inevitabely also its IPv6 address. For this reason, Stateless Autoconfiguration will be used primarily in small to medium sized organizations, and never in datacenter/hosting businesses which rely heavily on fixed IP addresses.
For Windows systems, a random MAC address will be generated to create a random IPv6 address which will be used for outgoing sessions. This will aid privacy, as your IP will never be the same (whereas the default Stateless Autoconfiguration will re-generate the same IP over and over again).