1. 程式人生 > >Windows下IPv6地址的形成和使用

Windows下IPv6地址的形成和使用

在使用Windows下的ifconfig或者ipv6 if命令檢視IPv6連線狀態的時候常常會看到一個網絡卡在global link上會有多個global address出現,如下:

ipconfig
Ethernet adapter 本地連線 :

Connection-specific DNS Suffix . :
Autoconfiguration IP Address. . . : 169.254.131.180
Subnet Mask . . . . . . . . . . . : 255.255.0.0
IP Address. . . . . . . . . . . . : 2001:da8:4000:23:2c76:a98d:d750:ee45

IP Address. . . . . . . . . . . . : 2001:da8:4000:23:78c9:fc49:595d:b8df

IP Address. . . . . . . . . . . . : 2001:da8:4000:23:2843:8803:747e:6dfe

IP Address. . . . . . . . . . . . : 2001:da8:4000:23:f97c:8bc7:bf88:454e

IP Address. . . . . . . . . . . . : 2001:da8:4000:23:398d:97ce:fd4d:b277

IP Address. . . . . . . . . . . . : 2001:da8:4000:23:a00:39ff:fe01:fbe7


IP Address. . . . . . . . . . . . : fe80::a00:39ff:fe01:fbe7%4
Default Gateway . . . . . . . . . : fe80::2e0:fcff:fe4f:1026%4

ipv6 if
Interface 4: Ethernet: 本地連線
Guid {CC74D20D-5CEA-4AE8-862A-C6A3FBF2F008}
uses Neighbor Discovery
uses Router Discovery
link-layer address: 08-00-39-01-fb-e7
preferred global 2001:da8:4000:23:2c76:a98d:d750:ee45, life 6d18h58m14s/18h5
5m27s (temporary)
deprecated global 2001:da8:4000:23:78c9:fc49:595d:b8df, life 5d19h1m5s/0s (t
emporary)
deprecated global 2001:da8:4000:23:2843:8803:747e:6dfe, life 4d19h3m57s/0s (
temporary)
deprecated global 2001:da8:4000:23:f97c:8bc7:bf88:454e, life 3d19h6m48s/0s (
temporary)
deprecated global 2001:da8:4000:23:398d:97ce:fd4d:b277, life 2d19h9m40s/0s (
temporary)

preferred global 2001:da8:4000:23:a00:39ff:fe01:fbe7, life 29d23h58m46s/6d23
h58m46s (public)

preferred link-local fe80::a00:39ff:fe01:fbe7, life infinite
multicast interface-local ff01::1, 1 refs, not reportable
multicast link-local ff02::1, 1 refs, not reportable
multicast link-local ff02::1:ff01:fbe7, 2 refs, last reporter
multicast link-local ff02::1:ff4d:b277, 1 refs, last reporter
multicast link-local ff02::1:ff88:454e, 1 refs, last reporter
multicast link-local ff02::1:ff7e:6dfe, 1 refs, last reporter
multicast link-local ff02::1:ff5d:b8df, 1 refs, last reporter
multicast link-local ff02::1:ff50:ee45, 1 refs, last reporter
link MTU 1500 (true link MTU 1500)
current hop limit 64
reachable time 20500ms (base 30000ms)
retransmission interval 1000ms
DAD transmits 1
default site prefix length 48

這個形式的多個全域性IPv6地址曾經使我很困惑,但是通過分析IPv6無狀態地址自動配置機制以及微軟提出的rfc3041“Privacy Extensions for Stateless Address Autoconfiguration in IPv6”,終於對此有了比較深入的瞭解。

這裡的多個地址中,最後一個
preferred global 2001:da8:4000:23:a00:39ff:fe01:fbe7, life 29d23h58m46s/6d23
h58m46s (public)
是固定的全域性地址,它可以手動配置或者由網路字首和硬體地址轉化成的介面標識聯合生成,在整個與網路相連的過程中,這個地址是始終不會變的
而之前的眾多地址
preferred global 2001:da8:4000:23:2c76:a98d:d750:ee45, life 6d18h58m14s/18h5
5m27s (temporary)
deprecated global 2001:da8:4000:23:78c9:fc49:595d:b8df, life 5d19h1m5s/0s (t
emporary)
deprecated global 2001:da8:4000:23:2843:8803:747e:6dfe, life 4d19h3m57s/0s (
temporary)
deprecated global 2001:da8:4000:23:f97c:8bc7:bf88:454e, life 3d19h6m48s/0s (
temporary)
deprecated global 2001:da8:4000:23:398d:97ce:fd4d:b277, life 2d19h9m40s/0s (
temporary)
雖然也是全域性地址,但是它們的作用與前者不一樣,它的作用是在使用者對外發起連線的時候充當連線發起的IPv6地址,這一行為的目的在於保證主機在對外通訊 時候的匿名性。這個地址是由路由字首和由主機隨機生成的介面標識組成的。這個地址是有有效期限制的,幾個小時或者幾天,在期間,系統一直以這個地址為主機 地址向外發出連線和請求。每一個時刻只有一個臨時地址是有效的,在一個地址過期時會立刻生成一個新的地址作為新的臨時地址。已經過期的地址不會立即被刪 除,它會儲存幾個小時或者幾天,此時過期的臨時地址不能對外發起連線,但是可以接受外部發來的之前請求的資訊。

微軟提出這個RCF的主要目的在於保證主機在對外通訊時候的匿名性,其原因在於在ipv6連線網路使用 Stateless Address Autoconfiguration 自動生成的全域性地址為如下形式AB,其中A是字首,B是主機根據硬體介面地址生成的介面標識,這樣,相像一下一個移動主機在網內移動的時候,雖然A是不斷 變化的,但是B始終是常量(而且是全域性唯一的),這樣就給人以跟蹤移動主機移動路線或者訪問站點的可能性,所以需要這樣一種帶有適當有效期長度的臨時 IPv6地址來對外發出網路請求。而根據硬體地址生成的那個全域性地址則可以作為伺服器地址來接受外界的主動連線請求。

參考資料:
[1]. http://technet2.microsoft.com/WindowsServer/en/library/01f5811d-589e-4c11-9161-0ce24a6f8a181033.mspx?mfr=true
[2]. http://www.ietf.org/rfc/rfc3041.txt
[3]. http://technet2.microsoft.com/WindowsServer/en/library/f953fa20-f037-4609-89eb-0178240f103b1033.mspx?mfr=true
[4]. http://www.microsoft.com/china/technet/itsolutions/network/ipv6/ipv6config.mspx
[5]. http://www.edu.cn/20051202/3163947.shtml 

轉載地址:http://hi.baidu.com/eqmcc/blog/item/c95f2d09daa66c87d1581be2.html