Read a sample: 1. Reading an IPv6 Address
An IPv6 address can look intimidating the first time it appears in a router configuration or troubleshooting output. Consider this example:
2001:0db8:0042:0000:0000:0000:0000:0017
The address is long, but it is not a random string. It is a 128-bit value written in a predictable format. Once you can identify its parts and recognize the accepted shortcuts, you can move between the long and short forms without changing the address itself.
That skill matters because network devices, documentation, and exam questions do not always display the same address in the same way. One source might show every leading zero; another might compress a long sequence of zeroes. Before deciding what an address is used for or which network it belongs to, you need to know exactly what you are reading.
This chapter builds that foundation. You will work with hexadecimal digits, expand and shorten addresses, and practice separating valid notation from strings that only look plausible.
IPv6 addresses are commonly written in hexadecimal, a base-16 numbering system. Hexadecimal uses sixteen symbols:
0 1 2 3 4 5 6 7 8 9 a b c d e f
The letters represent values after 9: a means ten, b means eleven, and so on through f, which means fifteen. Uppercase and lowercase letters have the same value, so A and a are interchangeable in an IPv6 address.
The advantage of hexadecimal is its compact relationship with binary. One hexadecimal digit represents four bits. For example:
Four hexadecimal digits therefore represent 16 bits. An IPv6 address has 128 bits, so its full hexadecimal form contains 32 hexadecimal digits.
You do not need to convert every address to binary to read it. You do, however, need to recognize which characters are allowed. The letter g, for instance, is not a hexadecimal digit. An address containing g is not valid IPv6 hexadecimal notation, regardless of how reasonable the rest of the address looks.
Hexadecimal is positional. In 0010, the 1 is in the sixteens position, so the value is sixteen in decimal. By contrast, 000f represents fifteen. For the notation exercises in this chapter, focus on preserving the digit positions rather than converting whole groups to decimal.
In its fully expanded form, an IPv6 address consists of eight groups of four hexadecimal digits. Colons separate the groups:
2001:0db8:0042:0000:0000:0000:0000:0017
Each 16-bit group is often called a hextet. Counting them gives:
Eight hextets multiplied by 16 bits gives the complete 128-bit address. The colons are separators; they are not additional address bits.
A hextet can have any value from 0000 through ffff. In an expanded address, each hextet has exactly four hexadecimal digits. In ordinary written notation, however, leading zeroes can be omitted. That is why a valid address may appear to have fewer than 32 visible digits even when no information has been lost.
The examples in this chapter use the 2001:db8::/32 documentation prefix. For now, treat /32 as a prefix-length annotation rather than part of the address itself. You will examine prefixes and their boundaries in the next chapter.
Within each hextet, you may remove zeroes from the beginning of the group:
Applying this rule to every hextet in the example gives:
2001:db8:42:0:0:0:0:17
The address is unchanged. The eight hextets are still present, and each one can be restored to four digits by adding zeroes on its left.
Leading-zero suppression does not permit you to remove zeroes from the middle or end of a hextet. For example, 1000 cannot be shortened to 1: those represent different 16-bit values. Likewise, 0102 can be written as 102, but not as 12.
A useful check is to expand the shortened hextet back to four digits. If you cannot recover the original by adding zeroes only on the left, the shortening changed the value.
A hextet consisting entirely of zeroes becomes 0 when you use leading-zero suppression alone. Do not simply leave an empty position between colons and assume it means one zero hextet. Empty positions are handled by a separate rule: the double colon.
A double colon, written ::, represents one or more consecutive all-zero hextets. It can appear at the beginning, in the middle, or at the end of an address.
Starting with:
2001:db8:42:0:0:0:0:17
the four consecutive zero hextets can be compressed:
2001:db8:42::17
The double colon does not specify its own length. You determine how many zero hextets it represents by counting the explicit hextets and supplying enough zero hextets to reach eight.
In this example, 2001, db8, 42, and 17 are explicit. That is four hextets, so :: represents the other four:
2001:0db8:0042:0000:0000:0000:0000:0017
The double colon can also represent zero hextets at an edge:
- ::17 expands to 0000:0000:0000:0000:0000:0000:0000:0017.
- 2001:db8:: expands to 2001:0db8:0000:0000:0000:0000:0000:0000.
- :: represents all eight zero hextets.
In every case, the result is still one 128-bit address. Later chapters will explain the purposes of particular addresses; here, the goal is to read their notation accurately.
An IPv6 address may contain at most one ::. If two appeared, a reader could not reliably determine how many zero hextets belonged at each location.
For example, this is invalid:
2001:db8::42::17
There are four explicit hextets, so four zero hextets would need to be supplied. But the notation gives no unambiguous way to divide those four between the two double colons.
By contrast, this is valid:
2001:db8:0:42::17
It has five explicit hextets, so the single :: represents exactly three zero hextets:
2001:0db8:0000:0042:0000:0000:0000:0017
The visible 0 is an explicit hextet.…