IPv6 addresses, like IPv4 addresses, internally are just strings of bits (128 of them in the case of IPv6). But humans are not good at working with long strings of bits, so we have “external data representation” for displaying IPv6 addresses in output for humans or accepting them as input from humans.IPv6 uses “Coloned-Hex” notation for external data representation (like “Dotted-Decimal”, but with colons instead of dots, and hexadecimal instead of decimal), which breaks the 128 bits into eight groups of sixteen bits each. Compare to IPv4 which has four groups of eight bits each. Fortunately the creators of IPv6 gave people more credit than the creators of IPv4 did. They didn’t worry about people asking “why are there letters in my numbers?” The creators of IPv6 chose to represent each sixteen bit group with an up to 4 digit hexadecimal (base 16) number. Sixteen bits can hold binary values from 0000 0000 0000 0000 to 1111 1111 1111 1111. In hexadecimal this is from 0x0000 to 0xffff. Nobody cares what 0xffff is in decimal! (If you must know, it’s 65,535.) If you just ran the eight hexadecimal groups together with no separators, you would not be able to leave off leading zeros and the result would be a bit much for most people. Without separators, a typical IPv6 address would look like this:
They added the “colon” as a separator between the eight sixteen-bit groups, which makes it much more readable, and also allows dropping leading zeros in each sixteen-bit group. With colons, and dropping the leading zeros, the above address looks like this:
Already this is a big improvement in readability (not to mention easier to enter). However, many IPv6 addresses have a long run of fields that are all zero (like this one). There is one more optimization with IPv6 external data representation – you can replace up to one run of zero fields with two colons (::). In effect, everything before the “::” is left justified in the 128 bits, and everything after the “::” is right justified. The part in between is all zeros. You can’t replace two runs of zero fields in a single address, because that would be ambiguous. So, the final external data representation of our IPv6 address looks like this:
This is now a major improvement over just 32 hex digits in a row.