IPv6 Address in C #

I am writing a socket server that requires the ability to allow / restrict IP, and I am trying to make it compatible with both IPv4 and IPv6.

I understand the principle of IPv4 well, for example, I can allow the use of 192.168.0.0/255.255.255.0 for all 192.168.0. * addresses based on my code http://blogs.msdn.com/b/knom/archive/2008/12/31/ip-address-calculations-with-c-subnetmasks-networks.aspx .

However, how does this work with IPv6? ie how to handle ranges with this protocol?

+3
source share
1 answer

IPv6 by convention does not use a subnet mask format such as IPv4. However, there is no reason why you cannot visualize it that way.

" " /64 IPv6 ffff:ffff:ffff:fffff:0:0:0:0. IPv6, , . IPv6 - - , /64,/48,/32 .. (, /64, ,/96, . )

ASCII, , IPv6:

2001:db8:1000:2000:3000:4000:5000:6000/32
<--net--><-------------------host---->

2001:db8:1000:2000:3000:4000:5000:6000/48
<--network--> <--------------host---->

2001:db8:1000:2000:3000:4000:5000:6000/64
<--network-------> <---------host---->

2001:db8:1000:2000:3000:4000:5000:6000/96
<--network------------> <----host---->

, , IPv4- ( , ). , IPv6 , IPv6 , , , 4, nybble (.. ) - -, IPv4!

, #. , , : .

+3

Source: https://habr.com/ru/post/1787062/


All Articles