Given IPv6 address 2001:0000:0000:0000:1111:0000:0000:0000
, should it be abbreviated as: 2001::1111:0:0:0
or 2001:0:0:0:1111::
? It seems I didn't see any specification talking about it.
1 Answer
From RFC5952 - IPv6 Text Representation
4.2.3. Choice in Placement of "::"
When there is an alternative choice in the placement of a "::", the
longest run of consecutive 16-bit 0 fields MUST be shortened (i.e.,
the sequence with three consecutive zero fields is shortened in 2001:
0:0:1:0:0:0:1). When the length of the consecutive 16-bit 0 fields
are equal (i.e., 2001:db8:0:0:1:0:0:1), the first sequence of zero
bits MUST be shortened. For example, 2001:db8::1:0:0:1 is correct
representation.
In short: 2001::1111:0:0:0
is correct.
-
1Well, both are correct, it's just that one notation is recommended :) All the given notations work equally well Mar 5, 2016 at 15:17
-
2Well, that depends a little on how much you're interested in following the RFC 5952 standard. The
MUST
doesn't give you a choice when doing a proper implementation - as RFC 2119 says about the use of keywords like MUSTin RFC documents ;) All this doesn't mean that some device or software might not accept an incorrectly abbreviated address.– xpacMar 5, 2016 at 15:23 -
3From the first paragraph of RFC 5952: "..., but all implementations must accept and be able to handle any legitimate RFC 4291 format.". The only addresses that are abbreviated incorrectly are those that don't follow RFC 4291. Everything that does must be accepted. Mar 5, 2016 at 15:56
-
2Agreed. Unless you claim your system/document/whatever being RFC 5952-compliant, this is just a recommendation ;)– xpacMar 5, 2016 at 16:59
-
5@SanderSteffann, the way it was explained to me is that, yes, your implementation needs to accept any RFC 4291 format as input, but because RFC 5952 is a Standards Track RFC, you should only output addresses in RFC 5952 format.– Ron Maupin ♦Mar 5, 2016 at 17:29