开发者

Query on IPv6 subnetting

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!


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?

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.

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?

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.

Also, in IPv6, is a prefix length /64 equivalent to 'ffff:ffff:ffff:ffff::'? How is the netmask represented in IPv6 address format?

Usually you don't, but 'ffff:ffff:ffff:ffff::' corresponds to a /64 netmask.


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.

255.0.0.0     ≡ ff00::      ≡ 8-bit prefix
255.255.0.0   ≡ ffff::      ≡ 16-bit prefix
255.255.192.0 ≡ ffff:C000:: ≡ 18-bit prefix

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:

IP#1 & NETMASK == IP#2 & NETMASK

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.


the standard Radix Tree (Trie) (Patricia ) implementation of the Route look up is available for IPv6 .

Netmask is represented as follows :

when we describe an IPv4 IP and network, we use a netmask to define the network. IPv6 has decided, rather than use the old 255.255.255.0 notation, that it's better just to use /# notation. So our netmask would be 128 to describe something similar to /32 (255.255.255.255) or one host. Note that expr 16 \* 8 gives us 128." [1]

[1] http://www.linux-sxs.org/networking/ipv6_for_beginners.html

[2] http://www.tldp.org/HOWTO/Linux+IPv6-HOWTO/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜