IPv6 in a Nutshell

Notation

IPv6 addresses are 128-bit numbers expressed in 8 groups of 16-bit big endian hexadecimals, with a colon separator. Leading zeros are dropped from each group, and the largest contiguous span of all zero groups are collapsed in to two colons with no other adjacent separators:

20 01 0d b8 00 00 00 fe 00 00 00 00 a7 00 37 b5

2001:db8:0:fe::a700:37b5

When used in a URL, the address must be wrapped in square brackets, this is so parsers can recognize whether or not a port number is following the address.

Structure

Addresses have a fixed structure of a 64-bit routing prefix followed by a 64-bit interface identifier. New addresses are generated by appending a randomly generated interface identifier to a chosen prefix.

When a network manages a pool of multiple routing prefixes, the prefix is logically divided in to the global routing prefix and the subnet identifier. Just as in IPv4, the subnet is arbitrarily large depending on where in the hierarchy the router is.

2001:0db8:7b10:00feRouting Prefix:0010:076b:a700:37b5Interface ID 2001:0db8:7b10:00fe:0010:076b:a700:37b5 2001:0db8:7b10Global Prefix:00feSubnet:0010:076b:a700:37b5

Even though IPv4 and IPv6 addresses have a different structure, they still have the same logical routing hierarchies, but IPv6’s are more deliberately designed:

Public Address(any unreserved address)
Global Unicast Address(2000::/4)
Private Address(192.168.0.0/16, etc.)
Unique Local Address(fd00::/8)
Link Local Address(169.254.0.0/16)
Link Local Address(fe80::/64%if)
Loopback Address(127.0.0.0/8)
Loopback Address(::1/128)

Discovery

When a node is first connected to any network, it assigns itself a link local address. Unlike IPv4, where link local addresses are usually only assigned as a fallback, in IPv6 interfaces always have a link local address.

The node will then perform a process called Stateless Address Autoconfiguration by sending a Router Solicitation message. If a Router Advertisement response is recieved, the message will include a list of prefixes that can be routed. The node will then assign itself an address on each prefix in the list that’s marked as autonomous. This list will usually include at least one unique local prefix defined by the router and at least one globally addressable prefix provided to the router by the ISP.

Every time a node assigns itself a new address, it will first perform a process called Duplicate Address Detection by sending a Neighbor Solicitation message. If the node recieves a Neighbor Advertisement, it’ll regenerate the identifier portion of the address as needed until it finds one that isn’t in use. This is done for any and all self assigned addresses, even global.

Delegation

When a router provides a list of prefixes to nodes for autoconfiguration, this is called prefix delegation. Router Advertisement messages may only delegate discrete prefixes, but DHCPv6 servers can delegate whole subnets to clients, so that those clients may further delegate to nodes downstream, as is usually necessary when the downstream node is on a different network segment.

DHCP also provides dynamic DNS in IPv6 just as it does in IPv4.

You may wonder, why do IPv6 networks require both router discovery and DHCP, when IPv4 only needs DHCP? At the time IPv6 was being developed, DHCPv4 was relatively new, and networks often used IPv4’s own router discovery protocol, so IPv6 was designed in kind. Eventually, DHCP adoption made IPv4 router discovery obsolete, but router discovery remains essential for IPv6’s address autoconfiguration even today.

NAT

When you first see the list of addresses assigned to your node, it may appear at first impression to be messy. Why should your device have so many IPv6 addresses when your network could just be behind a NAT instead?

Internet
↑↓
203.0.113.51
(Public Address)
↑↓
192.168.1.100
(Private Address)
Internet

↑↓
2001:db8:fed5:f647:43:6f8:79ee:c886
(Global Unicast Address)
fdd7:2d5:8bee::c58:b537:bae8:1a
(Unique Local Address)
fe80::9392:2:f936:9e6e%eno1
(Link Local Address)

NAT’s purpose has always been to work around IPv4’s limited address space; solving this problem is the very reason IPv6 was created. Contrary to popular folk wisdom, NAT is not an adequate substitute for a firewall, and so shouldn’t be relied upon as one.