How to understand IPv6 address and types
IPv6 uses 16 bytes (128 bits) to represent and IP address as opposed to 4 bytes (32 bits) in IPv4. IPv6 uses colon separated hexa-decimal notation as opposed to dotted-decimal notation in IPv4.With 128-bit long IP address size, IPv6 can provide 2^128 addresses. In a simple decimal notation, it takes up to 39 digits making it harder to memorize. To make it relatively convenient, an IPv6 address is represented by a series of 16 bit hexa-decimal values separated by colons. An example IPv6 address is as follows.
The leading zeros can be omitted for simplicity. The above IPv6 address looks like the following if leading zeros are omitted.
To simplify further, a sequence of 16 bit blocks containing only zeros can be replaced with “::”. But it should be used only once in the notation as “::” represents variable number of zero-valued 16 bit blocks.
The IPv6 address
2001:0da3:02f0:d413:0000:0000:0000:08a2 can be represented as 2001:0da3:02f0:d413::08a2
For example, the IPv6 address 0000:0000:0000:0000:0000:0000:0000:0001 is used as address for Loopback interface. After simplifying this address, it looks like “::1“.
[neo@techpulp ~]# ifconfig lo lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:6 errors:0 dropped:0 overruns:0 frame:0 TX packets:6 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:340 (340.0 b) TX bytes:340 (340.0 b) [neo@techpulp ~]#
Similar to IPv4, IPv6 addresses can be split into network and host parts using subnet masks. You can add any number of IPv6 address to same network interface that is similar to interface aliasing for the purpose of assigning multiple IPv4 addresses.
IPv6 supports three types of addresses that can be categorized by type and scope.
A unicast address specifies a single interface. A packet sent to a unicast address travels from one host to the destination host.
There are three types of unicast addresses based on scope.
These addresses are designed to be used on single local link. Link-local addresses are automatically calculated on all local interfaces in a system. These addresses carry fe80::/10 as address prefix. Routers don’t forward packets containing Link-local address as source or destination IP address.
These addresses are designed to be used with in a specific site. Site-local addresses carry fec0::/10 as address prefix. Routers don’t forward packets with site-local address outside of a specific site.
These addresses are designed to be used in any network. Global addresses carry binary 001 as prefix. Routers forward packets with global addresses across networks.
There are two special types of unicast addresses:
The IPv6 address 0:0:0:0:0:0:0:0 indicates the absence of IP address assigned to an interface. This is typically used as source IP address while discovering an IP address from a DHCP server. This is similar to the IPv4 address “0.0.0.0″. This IPv6 address can be abbreviated as “::”.
The loopback address 0:0:0:0:0:0:0:1 is used to send the packet to itself. This is similar to IPv4 address “127.0.0.1″. The loopback IPv6 address can be abbreviated as “::1″.
A multicast address specifies multiple interfaces. These interface may be at different locations. Multicast addresses carry “ff” as address prefix. A packet destined to a multicast address is copied to each member of the multicast group.
Anycast address specifies a set of interfaces located at different places but using same IP address. A packet destined to anycast address is delivered to the nearest member of the group. Anycast address cannot be used as source IP address, they are only used as destination address. These address are used to cover service like nearest DNS server, DHCP server etc. This kind of addresses are handled by dynamic routing protocols. There is no special prefix assigned to Anycat IP address and they are taken out of Unicast address space.