IPv6子网划分查询
假设给出两个 IPv6 地址 ip1 (abc::1/64)、ip2 (abc::2/64),确定它们是否属于同一子网的算法是什么?
对于 IPv4,一个地址中的每个八位字节都用子网八位字节进行掩码,并将结果与第二个地址的类似练习的结果进行比较。我们可以对 IPv6 地址中的每个十六进制执行类似的操作吗?
另外,在 IPv6 中,前缀长度 /64 是否相当于“ffff:ffff:ffff:ffff::”? IPv6 地址格式中的网络掩码如何表示?
谢谢!
Supposing two IPv6 addresses ip1 (abc::1/64), ip2 (abc::2/64) are given, what's the algorithm to determine if they're part of the same subnet or not?
For IPv4, each octet in one address is masked with the subnet octet and the result compared with the result of a similar exercise for the second address. Could we do a similar thing for the each hextet in the IPv6 address?
Also, in IPv6, is a prefix length /64 equivalent to 'ffff:ffff:ffff:ffff::'? How is the netmask represented in IPv6 address format?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果前 64 位相等,则它们位于同一子网上。这些是地址中的前四个“块”。如果您写入完整地址,它们将变为 0abc:0000:0000:0000:0000:0000:0000:0001 和 0abc:0000:0000:0000:0000:0000:0000:0002。前 64 位(0abc:0000:0000:0000: 部分)相等,因此它们位于同一子网中。
实际上,您屏蔽的是位,而不是八位位组。但您仍然可以使用相同的技术。将地址转换为位,并使用与前缀长度对应的位序列对其进行掩码。因此,/64 将是值为 1 的 64 位,后跟值为 0 的 64 位。对于 /48,它将是值为 1 的 48 位,后跟值为 0 的 80 位。
通常不需要,但 'ffff:ffff:ffff:ffff::' 对应于 /64 网络掩码。
They are on the same subnet if the first 64 bits are equal. These are the first four 'blocks' in the address. If you write the full addresses they become 0abc:0000:0000:0000:0000:0000:0000:0001 and 0abc:0000:0000:0000:0000:0000:0000:0002. The first 64 bits (the 0abc:0000:0000:0000: part) is equal, so they are on the same subnet.
Actually, you mask the bits, not the octet. But you can still use the same technique. Convert the address to bits and mask it with a bit sequence corresponding to the prefix length. So a /64 would be 64 bits with value 1 followed by 64 bits with value 0. For a /48 it would be 48 bits with value 1 followed by 80 bits with value 0.
Usually you don't, but 'ffff:ffff:ffff:ffff::' corresponds to a /64 netmask.
IPv4 网络掩码有点假,因为它允许人们指定 255.0.0.255 等掩码。 IPv6 通过将术语“前缀长度”定义为网络掩码中连续位的长度来澄清这一点。
如果您有两个地址(IP#1 和 IP#2)以及网络掩码 NETMASK,则要测试这两个地址是否在同一网络中,则以下条件必须为真:
这对于 IPv4 和 IPv6 都适用,因此所需要做的就是将 IPv6 前缀长度转换为更易于在测试中使用的网络掩码。
IPv4 netmasks are a bit bogus because it allows people to specify masks like 255.0.0.255. IPv6 clarifies this by defining the term "prefix length" as the length of contiguous bits in the netmask.
If you have two addresses, IP#1 and IP#2 and a netmask NETMASK then to test if the two addresses in the same network then the following must be true:
This extends true for both IPv4 and IPv6, so all that is necessary is to convert IPv6 prefix lengths into a netmask that is easier to use in the test.
路由查找的标准基数树 (Trie) (Patricia) 实现可用于 IPv6。
网络掩码表示如下:
[1] http://www.linux-sxs.org/networking/ipv6_for_beginners.html
[2] http://www.tldp.org/HOWTO/Linux+IPv6-HOWTO/
the standard Radix Tree (Trie) (Patricia ) implementation of the Route look up is available for IPv6 .
Netmask is represented as follows :
[1] http://www.linux-sxs.org/networking/ipv6_for_beginners.html
[2] http://www.tldp.org/HOWTO/Linux+IPv6-HOWTO/