Address Notations In IPv6

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, March 18, 2010

Follow me on Twitter as @mattiasgeniar

From a visual point-of-view, the biggest change from IPv4 to IPv6 is the way addresses are formed. The IPv4 way of writing addresses, is by placing four 8 bit groups, seperated by a point “.".

  • 127.0.0.1 (local loopback)
  • 10.0.0.1 (typical local IP address)
  • 193.239.210.183 (public IP address of this blog)

IPv6 uses eight 16-bit hexadecimal values, seperated by a colon “:".

  • ::1 (local loopback)
  • fec0::3010:2ffe:fe21:2640 (typical local IP address)
  • 2001:db2:31:1041:204a::1337 (random public IPv6 address)

The first thing you should know, is that IPv6 addresses can be abbreviated. The local loopback address, written in the example as “::1", is actually the shortened version of 0000:0000:0000:0000:0000:0000:0000:0001.

Leading zeros in IPv6 can usually be left out. This would shorten our local loopback address to 0:0:0:0:0:0:0:1.

To further reduce the length of the address (and add to its confusion, at first), one sequence of zeros, seperated by colons, can be removed and replaced by a double colon “::". Since our example holds seven zero’s, it’s shortened to ::1.

For instance, the IPv6 address 2001:af40:0401:0000:0000:a401:0000:f010 can be abbreviated like this.

2001:af40:0401:0000:0000:a401:0000:f010 (full form)

2001:af40:0401::a401:0000:f010 (series of zeros replaced by ::)

2001:af40:401::a401:0:f010 (leading zeros removed)

Replacing a series of zeros, can only occur once. The following isn’t a legal IPv6 address: 2001:af1**::**50:1002**::**5, because there is no way to determine if the address should be

2001:af1**:0:0:**50:1002**:0:**5

or

2001:af1**:0:**50:1002**:0:0:**5

Since IPv6 no longer uses points to seperate values, but colons, it poses a direct problem for specifying portnumbers, as its default notation is :. This can be solved by placing the IP address in between brackets, such as [::3]:8080 (which addresses the local loopback address, on port 8080). For websites that use the IP for access, this should be http://[ip-address]:port.



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.