IPv6 Address Format
An IPv6 address is 128 bits long, allowing for a total of 3.4×1038 or exactly 340,282,366,920,938,463,463,374,607,431,768,211,456 addresses.
An IPv6 address is represented by 32 hexadecimal characters. This is arranged as eight fields of four characters, separated by colons (:). These hex characters include the numerals 0-9 and the letters a-f. Each group of four characters represents 16 bits.
It is recommended that the lower case letters (a-f) be used in preference to upper case to avoid confusion between B and 8 and D and 0.
Leading zeros in a group of four hex digits are suppressed as follows:
Multiple, adjacent fields of zeros are replaced by the double colon (::), a technique known as zero compression. This can only be done once in an IPv6 address. If there are two places where the zero compression could be used, it is applied to the longest sequence. If both sequences are the same size then the first sequence from the left is to be used.
and is further shortened to:
when both zero compression and zero suppression are used.
Types of Addresses
In IPv4, we normally had only a single IPv4 address for a host device (eg PC, server). If the device had more than one Network Interface Card then we assigned another address for that interface.
In IPv6, is is common for each interface to have several addresses. A host computer could have several interfaces and each interface can have several addresses. Typically, every interface has the "localhost" or "loopback" address (127.0.0.1 in IPv4) in IPv6 it is simply ::1 as well as a link-local address and a global address.
A commonly used term in IPv6 is prefix. This just means the network part of the IP address, similar to what we get when we split an IPv4 address into network and host parts by applying a subnet mask. Prefixes are written with a "/" and a number indicating how many bits are significant, the same was we used Variable Length Subnet Masks in IPv4. For example the prefix 2001:db8::/32 indicates 32 bits are used for the network address which is in the range from 2001:000 through to 2001:ffff.
An interface has an address for the local network known as the link-local address. This has the prefix of fe80::/10 and like the APIPA address for IPv4 (169.254.x.x) it can only be used to communicate with nodes on the local network.
You may read about a site-local address of fec0::/10 in older IPv6 publications. This concept has been discontinued so you can simply ignore any documentation about site-local addresses.
To access the Internet, an interface requires a global address which has a prefix of 2000::/3. This means that any IPv6 address that starts with 2000: through to 3fff: will fall into this range. These are routable on the Internet and all routers are required to forward them.
IPv6 does not use broadcast addresses at all but does has multicast addresses with a prefix of ff00::/8. If multicasting is being used on your network then your interfaces will also have IPv6 multicast addresses.
Note: A special prefix is 2001:0db8::/32 which is reserved for documentation only. It MUST NOT be assigned to interfaces and routers will not forward packets with this prefix.
Prefixes, Subnets and Interface ID's
An interface typically has a 128 bit IPv6 address that is comprised of a Prefix, Subnet ID and an Interface ID. The prefix is assigned by the Regional Internet Registry or the ISP and will vary in length based on the size of the organisation. Typical lengths are /32 /48 and /56. The remainer up to 64 bits can be used for individual subnet IDs. The last 64 bits is assigned to the Interface ID.
Allocating an Interface ID
Like IPv4, There are two methods that can be used to assign the Interface ID (the IPv4 Host ID). One is to statically assign the address by manually typing it in like you may do on a server. The second is automatic configuration which can be done via DHCPv6 or SLAAC. DHCPv6 is essentially the same as DHCP for IPv4 but with IPv6 addresses.
SLAAC (StateLess Address Automatic Configuration) is a method of automatically assigning an IPv6 address without the need for a DHCP server. There are two methods to do generate the address. The first is called EUI-64 and uses the MAC address (see Appendix A of RFC 4291 for how this works). The second is a randomly generated number (to ensure privacy) as described in RFC 3041.