{"id":58,"date":"2012-02-13T22:28:29","date_gmt":"2012-02-14T05:28:29","guid":{"rendered":"http:\/\/www.ipcalypse.ca\/?p=58"},"modified":"2012-08-21T21:32:23","modified_gmt":"2012-08-22T03:32:23","slug":"writing-an-ipv6-address-the-6-commandments-of-rfc5952","status":"publish","type":"post","link":"https:\/\/www.ipcalypse.ca\/?p=58","title":{"rendered":"Writing an IPv6 Address &#8211; The 6 Commandments of RFC5952"},"content":{"rendered":"<p>When we write down IPv4 addresses, no one really has to go over just how you write them.  Most people get it after only  a little while of seeing it done.  4 sets of numbers, from 0 to 255, each separated by a &#8220;.&#8221;.<br \/>\nWhen IPv6 started to be developed, it quickly became apparent that there needed to be an easier way to write it out than (for example)<br \/>\n2001:0db8:0000:0000:0000:0000:0000:0001.<br \/>\nEven if you quickly realize that you could drop the leading zeros (as we naturally do in &#8220;dotted decimal&#8221;), it&#8217;s still fairly unwieldy:<br \/>\n2001:db8:0:0:0:0:0:1<br \/>\neven if it is much better.<br \/>\nSo the idea of the double colon was introduced to combine sets of zero&#8217;s together.  The first RFC&#8217;s said that 1 or more groups of 16 bits of zeros could be combined to &#8220;::&#8221;<br \/>\n2001:db8::1<br \/>\nThat&#8217;s almost usable!  Of course it won&#8217;t always go that easily, especially if you start using SLAAC to configure your network:<br \/>\n2001:db8::93e6:baff:febd:6533<br \/>\nDarn.  But still better than nothing.<br \/>\nUnfortunately, even with these rules, there wasn&#8217;t enough of them for the machines who are the ultimate users of these.  By the rules that are defined in earlier RFC&#8217;s, all of these are valid:<br \/>\n2001:db8::1<br \/>\n2001:0db8::1<br \/>\n2001:0db8:0::1<br \/>\n2001:0db8:0::0:0001<br \/>\n(etc)<br \/>\nand case wasn&#8217;t ever discussed either:<br \/>\n2001:dB8:0::DeAd:BEEF<br \/>\nis perfectly legit.<br \/>\nThis makes it harder to write code for things that need to decode these addresses.  And <a href=\"https:\/\/tools.ietf.org\/html\/rfc5952\">RFC 5952<\/a> was written to try and address these shortcomings.<\/p>\n<p><b>Here are the 6 commandments of RFC 5952:<\/b><br \/>\n1) Thou shalt not SHOUT your IPv6 address.  <\/p>\n<ol>IPv6 must be written in lowercase.  2001:db8::1 not 2001:DB8::1<\/ol>\n<p>2) Thou shall destroy leading zeros.<\/p>\n<ol>Always truncate leading zeros. 2001:0db8::1 is not acceptable, you must use 2001:db8::1<\/ol>\n<p>3) Thou shalt not use the double colon where there is only one 16 bit set of zeros.<\/p>\n<ol>If you only have one set of 4 zeros, you can no longer use the double colon, instead it just gets shortened to one zero. An address such as 2001:db8:0000:4:5:6:7:8 can&#8217;t use the double colon and only gets shortened to 2001:db8:0:4:5:6:7:8<\/ol>\n<p>4) Thou shall use the double colon to it&#8217;s greatest potential.<\/p>\n<ol>If you have multiple sets of more than 8 zeros, you have to use the set with the most zeros. So if you have 2001:db8:0000:0000:1:0000:0000:0000 you have to use the double colon on the right set of 0&#8217;s &#8211; 2001:db8:0:0:1::<\/ol>\n<p>5) Wheresoever thou has two places to use the double colon, thou shall use the leftmost.<\/p>\n<ol>If there are 2 equal sets of zeros, use the double colon on the one on the left, and single zeros on the right. 2001:db8:0000:0000:1:0000:0000:1 would become 2001:db8::1:0:0:1<\/ol>\n<p>6) Thou shall use the square brackets to separate IPv6 address from thy port number.<\/p>\n<ol>When writing an IPv6 address with a port number, use square brackets around the IPv6 address to keep confusion at bay, since ports are appended with a : (the same separator as IPv6 sections): [2001:db8::1]:80  With the square brackets, we know it&#8217;s IPv6 address 2001:db8::1 on port 80, not IPv6 address 2001:db8::1:80<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>When we write down IPv4 addresses, no one really has to go over just how you write them. Most people get it after only a little while of seeing it done. 4 sets of numbers, from 0 to 255, each separated by a &#8220;.&#8221;. When IPv6 started to be developed, it quickly became apparent that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,40],"tags":[10,9],"class_list":["post-58","post","type-post","status-publish","format-standard","hentry","category-ipcalypse","category-ipv6","tag-how-to-write-an-ipv6-address","tag-rfc-5952"],"_links":{"self":[{"href":"https:\/\/www.ipcalypse.ca\/index.php?rest_route=\/wp\/v2\/posts\/58","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ipcalypse.ca\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ipcalypse.ca\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ipcalypse.ca\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ipcalypse.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=58"}],"version-history":[{"count":14,"href":"https:\/\/www.ipcalypse.ca\/index.php?rest_route=\/wp\/v2\/posts\/58\/revisions"}],"predecessor-version":[{"id":181,"href":"https:\/\/www.ipcalypse.ca\/index.php?rest_route=\/wp\/v2\/posts\/58\/revisions\/181"}],"wp:attachment":[{"href":"https:\/\/www.ipcalypse.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=58"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ipcalypse.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=58"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ipcalypse.ca\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=58"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}