RFC 4291, IP Version 6 Addressing Architecture, Appendix A has the full explanation.
Basically, you split the 48-bit MAC address down the middle, insert
FFFE to extend it to 64 bits, and flip the U/L bit. This creates the 64-bit Interface ID which you append to the end of the 64 bits of the Global Routing Prefix and Subnet ID combination. For Link-local addresses, the created Interface ID is appended to the Link-local prefix (
Some people are concerned that you can use a unique number, like a MAC address, to track a particular host. To correct this, RFC 4941, Privacy Extensions for Stateless Address Autoconfiguration in IPv6 was created. Windows and many Linux variants use random addressing by default, but this may be disabled.