This is still the header! Main site

How to read IPv6 addresses

2022/03/13
This is post no. 93 for Kev Quirk's #100DaysToOffload challenge. The point is to write many things, not to write good ones. Please adjust quality expectations accordingly :)

They are waay too long. And inconvenient. And generally confusing. IPv6 addresses are typically the thing you just skip over. Like... if you just look at the one that google.com has (... from here, at least):

2607:f8b0:4005:813::200e

They... aren't that evil though. We'll look at them more in today's post!

... what's that "::" part???

IPv4 is simple: it's just four numbers, with dots.

Yet another Google example: 142.251.46.238.

IPv6 does look like it's some kind of variable length weirdness, but it's not: the "::" part is just zeroes. So... the full address of that above Google server is:

2607:f8b0:4005:0813:0000:0000:0000:200e

When expanded, they're always 8 of these 2-byte (16 bit) groups, adding up to the full 128-bit address. Just for fun, this is how it'd look like if we kept using the IPv4 notation:

36.7.248.11.64.5.8.19.0.0.0.0.0.0.32.14

... which is definitely longer than the original... not too sure which one is worse to write / remember though.

Subnets?

For IPv4, we do know that something that looks like 142.251.46.238 is likely a public IP address; 192.168.5.123 or 100.2.3.4 is an internal, non-routeable, LAN one, and 127.0.0.1 is localhost. So... what are the IPv6 equivalents?

Actually, part of the point of having IPv6 at all is so that we don't really have to have local-only IPs anymore. As in: when you connect to a network that gives you an IPv6 address, that address is usually a globally routeable one. (... which doesn't mean you can necessarily connect to it; there might be still firewalls between you and the open internet. At least you do have a global name though.)

Nevertheless, they still have parts that correspond to public and local addresses though!

E.g. let's say your ISP gives you an address that looks like this:

2601:5005:6006:f00d:1234:5678:90ab:cdef

ISPs will typically give you at least entire 64-bit subnet; it is from this address space that your router will hand out IPs, either via SLAAC or (stateful) DHCPv6. Thus, you can generally assume that the left half of the entire address is shared by all of the machines on your LAN. So... you can parse an address like this:

You cut it in half.

Using the above example, the left side, 2601:5005:6006:f00d, is what your ISP gave you. The left side of this, e.g. 2601:5005, will be ISP-specific, e.g. it looks like Google has a lot of addresses starting with 2607. Meanwhile, if you want to check whether you are still on the same subnet / public IP allocation, you can look at the rightmost part of this: e.g. f00d is what tells apart your home LAN from other networks from the same ISP in the area. If you ever want to quickly go like "yes that's my IP address" with an IPv6 address, that's the part to look at.

Meanwhile, the right 64 bits is the part that changes within your network; in a way, they correspond to your "192.168.5.105" local IPs. Of course, these are still too large to remember; they are reasonably random though, so just by comparing the rightmost 2 bytes you can recognize IPs of various machines.

To summarize:

... comments welcome, either in email or on the (eventual) Mastodon post on Fosstodon.