An IPv6 address is 128 bits long and is written as eight groups of four hexadecimal digits (base 16 digits represented by the numbers 0-9 and the letters A-F). Each group is separated by a colon (:). For example, FC00:0000:130F:0000:0000:09C0:876A:130B is a complete and valid IPv6 address.
For convenience, IPv6 addresses can be written in a compressed format. Taking the IPv6 address FC00:0000:130F:0000:0000:09C0:876A:130B as an example:
An IPv6 address can contain only one double colon (::). Otherwise, a computer cannot determine the number of zeros in a group when restoring the compressed address to the original 128-bit address.
IPv6 addresses have two parts:
Network prefix: Corresponds to the network ID of an IPv4 address. It is comprised of n bits.
Interface identifier (interface ID): Corresponds to the host ID of an IPv4 address. It is comprised of 128-n bits.
If the first 3 bits of an IPv6 unicast address are not 000, the interface ID must contain 64 bits. If the first 3 bits are 000, there is no such limitation.
You can manually configure the interface ID, generate it through system software, or generate it in IEEE 64-bit Extended Unique Identifier (EUI-64) format. Generating an interface ID in EUI-64 format is the most common practice.
IEEE EUI-64 standards convert an interface MAC address into an IPv6 interface ID. Figure 1 shows a 48-bit MAC address. When used as an interface ID, the first 24 bits (expressed by c) are a vendor identifier, and the last 24 bits (expressed by m) are an extension identifier. If the higher seventh bit is 0, the MAC address is locally unique. During conversion, EUI-64 inserts FFFE between the vendor identifier and extension identifier. The higher seventh bit also changes from 0 to 1 to indicate that the interface ID is globally unique.
For example, if the MAC address is 000E-0C82-C4D4, the interface ID is 020E:0CFF:FE82:C4D4 after the conversion.
Converting MAC addresses into IPv6 interface IDs reduces the configuration workload. When using stateless address autoconfiguration, you only need an IPv6 network prefix to obtain an IPv6 address. One defect of this method, however, is that an IPv6 address is easily calculable based on a MAC address, and could therefore be used for malicious attacks.
IPv6 addresses can be classified as unicast, multicast, or a new class called anycast. Unlike IPv4, there is no broadcast IPv6 address. Instead, a multicast address can be used as a broadcast address.
IPv6 Unicast Address
An IPv6 unicast address identifies an interface. Since each interface belongs to a node, the IPv6 unicast address of any interface can identify the relevant node. Packets sent to an IPv6 unicast address are delivered to the interface identified by that address.
IPv6 defines multiple types of unicast addresses, including the unspecified address, loopback address, global unicast address, link-local address, and unique local address.
Unspecified address
The IPv6 unspecified address is 0:0:0:0:0:0:0:0/128 or ::/128, indicating that an interface or a node does not have an IP address. It can be used as the source IP address of some packets, such as Neighbor Solicitation (NS) messages, in duplicate address detection. Devices do not forward packets with an unspecified address as the source IP address.
Loopback address
The IPv6 loopback address is 0:0:0:0:0:0:0:1/128 or ::1/128. Similar to the IPv4 loopback address 127.0.0.1, the IPv6 loopback address is used when a node needs to send IPv6 packets to itself. This IPv6 loopback address is usually used as the IP address of a virtual interface, such as a loopback interface. The loopback address cannot be used as the source or destination IP address of packets needing to be forwarded.
Global unicast address
An IPv6 global unicast address is an IPv6 address with a global unicast prefix, which is similar to an IPv4 public address. IPv6 global unicast addresses support route prefix summarization, helping limit the number of global routing entries.
Figure 2 shows a global unicast address consisting of a global routing prefix, subnet ID, and interface ID.
These components are described as follows:
Global routing prefix: is assigned by a service provider to an organization. A global routing prefix is comprised of at least 48 bits. Currently, the first 3 bits of every assigned global routing prefix is 001.
Subnet ID: is used by organizations to construct a local network (site). Similar to an IPv4 subnet number, there are a maximum of 64 bits for both the global routing prefix and subnet ID.
Interface ID: identifies a device (host).
Link-local address
Link-local addresses are used only in communication between nodes on the same local link. A link-local address uses a link-local prefix of FE80::/10 as the first 10 bits (1111111010 in binary) and an interface ID as the last 64 bits.
When IPv6 runs on a node, a link-local address that consists of a fixed prefix and an interface ID in EUI-64 format is automatically assigned to each interface of the node. This mechanism enables two IPv6 nodes on the same link to communicate without any configuration, making link-local addresses widely used in neighbor discovery and stateless address configuration.
Devices do not forward IPv6 packets with the link-local address as a source or destination address to devices on different links. Figure 3 shows the link-local address format.
Unique local address
Unique local addresses are used only within a site. Site-local addresses, according to RFC 3879, have been replaced by unique local addresses.
Unique local addresses are similar to IPv4 private addresses. Any organization that does not obtain a global unicast address from a service provider can use a unique local address. However, they are routable only within a local network, not the Internet as a whole. Figure 4 shows the unique local address format.
These components are described as follows:
Prefix: is fixed as FC00::/7.
L: is set to 1 if the address is valid within a local network. The value 0 is reserved for future expansion.
Global ID: indicates a globally unique prefix, which is pseudo-randomly allocated (for details, see RFC 4193).
Subnet ID: identifies a subnet within the site.
Interface ID: identifies an interface.
IPv6 Multicast Address
Like IPv4 multicast addresses, IPv6 multicast addresses identify groups of interfaces, which usually belong to different nodes. A node may belong to any number of multicast groups. Packets sent to an IPv6 multicast address are delivered to all the interfaces identified by the multicast address. For example, the multicast address FF02::1 indicates all nodes within the link-local scope, and FF02::2 indicates all routers within the link-local scope.
Figure 5 shows the IPv6 multicast address format.
Solicited-node Multicast Address
A solicited-node multicast address is generated using an IPv6 unicast or anycast address of a node. When a node has an IPv6 unicast or anycast address, a solicited-node multicast address is generated for the node, and the node joins the multicast group that corresponds to its IPv6 unicast or anycast address. Each unicast or anycast address corresponds to a single solicited-node multicast address, which is often used in neighbor discovery and duplicate address detection.
IPv6 does not support broadcast addresses or Address Resolution Protocol (ARP). In IPv6, Neighbor Solicitation (NS) packets are used to resolve IP addresses to MAC addresses. When a node needs to resolve an IPv6 address to a MAC address, it sends an NS packet in which the destination IP address is the solicited-node multicast address corresponding to the IPv6 address. Only the nodes with this multicast address are checked and processed.
The solicited-node multicast address consists of the prefix FF02::1:FF00:0/104 and the last 24 bits of the corresponding unicast address.
IPv6 Anycast Address
An anycast address identifies a group of network interfaces, which usually belong to different nodes. Packets sent to an anycast address are delivered to the nearest interface that is identified by the anycast address, depending on the routing protocols.
Anycast addresses implement redundancy backup and load balancing functions when multiple hosts or nodes are provided with the same services. Currently, a unicast address is assigned to more than one interface to make a unicast address become an anycast address. When sending data packets to anycast addresses, senders cannot determine which of the assigned devices will receive the packets. Which device receives the packets depends on the routing protocols running on the network. Anycast addresses are used in stateless applications, such as Domain Name Service (DNS).
IPv6 anycast addresses are allocated from the unicast address space. Mobile IPv6 applications also use anycast addresses.
IPv6 anycast addresses can be assigned only to routing devices but not hosts. Anycast addresses cannot be used as the source IP addresses of IPv6 packets.
Subnet-router Anycast Address
RFC 3513 predefines a subnet-router anycast address. Packets sent to a subnet-router anycast address are delivered to the nearest device on the subnet identified by the anycast address, depending on the routing protocols. All devices must support subnet-router anycast addresses. A subnet-router anycast address is used when a node needs to communicate with any of the devices on the subnet identified by the anycast address. For example, a mobile node needs to communicate with one of the mobile agents on the home subnet.
In a subnet-router anycast address, the n-bit subnet prefix identifies a subnet, and the remaining bits are padded with 0s. Figure 6 shows the subnet-router anycast address format.