IPv6 地址缩写

网络工程 IPv6
2022-02-04 07:17:40

给定 IPv6 地址2001:0000:0000:0000:1111:0000:0000:0000,它应该缩写为:2001::1111:0:0:0还是2001:0:0:0:1111::似乎我没有看到任何规范在谈论它。

1个回答

来自RFC5952 - IPv6 文本表示

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.

简而言之:2001::1111:0:0:0是正确的。