IPv6 切割子網域實驗


hosta --> fec0::a00:27ff:fe9a:a828
hostb --> fec0::10:a00:27ff:fe95:f91c

實驗1:prefix為63

[root@hosta ~]# ifconfig eth0 | grep Scope:Site
    inet6 addr: fec0::a00:27ff:fe9a:a828/64 Scope:Site

[root@hostb ~]# ifconfig eth0 | grep Scope:Site
    inet6 addr: fec0::1:a00:27ff:fe95:f91c/64 Scope:Site

主機分屬於feco:0000:0000:000及feco:0000:0000:001兩個網段,互ping不成功

[root@hosta ~]# ping6 -I eth0 fec0:0000:0000:0010:a00:27ff:fe95:f91c
PING fec0:0000:0000:0010:a00:27ff:fe95:f91c(fec0::10:a00:27ff:fe95:f91c) from fec0::a00:27ff:fe9a:a828 eth0: 56 data bytes
^C
--- fec0:0000:0000:0010:a00:27ff:fe95:f91c ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3602ms


實驗2:prefix為56

[root@hosta ~]# ifconfig eth0 | grep Scope:Site
    inet6 addr: fec0::a00:27ff:fe9a:a828/56 Scope:Site

[root@hostb ~]# ifconfig eth0 | grep Scope:Site
    inet6 addr: fec0::1:a00:27ff:fe95:f91c/56 Scope:Site

主機同屬於feco:0000:0000:00網段,互ping成功

[root@hosta ~]# ping6 -I eth0 fec0:0000:0000:0010:a00:27ff:fe95:f91c
PING fec0:0000:0000:0010:a00:27ff:fe95:f91c(fec0::10:a00:27ff:fe95:f91c) from fec0::a00:27ff:fe9a:a828 eth0: 56 data bytes
64 bytes from fec0::10:a00:27ff:fe95:f91c: icmp_seq=1 ttl=64 time=2.74 ms
64 bytes from fec0::10:a00:27ff:fe95:f91c: icmp_seq=2 ttl=64 time=0.753 ms
64 bytes from fec0::10:a00:27ff:fe95:f91c: icmp_seq=3 ttl=64 time=0.686 ms

由上實驗可知,IPv6在分割子網域上比IPv4方便,只需使用prefix即可。
在實驗的過程中,自己忽略了一件事,IPv6的是使用16進位來計算,
而prefix的是指2進位位元的位置,所以在計算上才會發現prefix在63、62時,
還是分屬不同的子網段,直到prefix在59時才是相同子網段,
這個結果與自己所預期的不同。原因如下:

以feco:0000:0000:0010:a00:27ff:fe95:f91c的第四組數字0010來計算。
16進位 ->  0010
 2進位 ->  0000 0000 0000 0001 0000

所以16進位的1,由右至左在位置2,但是對於2進位而言,其位置卻是在5。



Oracle Data Gurad Archive Gap