# IPv6 - (Global Unicast) Address [TOC] ## 影片資源 ### IPv6 Fundamentals: Purpose and Format of GUA {%youtube GKY8ilBIZWQ %} ### Subnetting IPv6 Addresses {%youtube UIGVPvxnCtk %} ### Discovering IPv6 with Wireshark (SF21VEU) {%youtube B8bNidd7Kdc %} ### IPV6 Security Assessment Tools (Jeff Carrell) {%youtube yNoBIpWt-v8 %} ## 簡介 在 IPv6 中,Global Unicast Address 的地位和 IPv4 中的 Public IP 一樣,用來作為在整個網際網路上的識別號碼。而目前為止所分配出去的 Global Unicast Address 都是 `2000::/3` 中的所有地址。所以看到一個 IPv6 位址的前 3 位元是 `001`,就會知道這是一個 Global Unicast Address。舉例來說,Facebook 是 `2a03:2880:f10c:83:face:b00c:0:25de`。 IPv6 一般性的敘述定義在 [RFC4291](https://datatracker.ietf.org/doc/html/rfc4291),而而 Global Unicast Address 的敘述定義在 [RFC3587](https://datatracker.ietf.org/doc/html/rfc3587)。 ## 格式:分成前後 64 位元 原先的 IPv4 中,一個 Class 的 IP 可以再分割成多個 subnet; 或著多個連續的 IP 位址可以藉由 CIDR,將小的 IP 網段合併成一個較大的網段。而不管是哪一種方法,兩者都是藉由 IP 的前綴來作為封包路由的依據。而這個前綴的長度,則可能會因為該 IP 所屬的 Class 不同,或是 CIDR 中合併的小網段數目的不同,而有不同長度。 在 IPv6 中,採取的是相反的作法。不像 IPv4 分成 A, B, C 等級而有不同的前綴,一個 IPv6 的位址一律都是以前 64 位元作為那個路由用的前綴: ``` | n bits | 64-n bits | 64 bits | +-------------------------+-----------+----------------------------+ | global routing prefix | subnet ID | interface ID | +-------------------------+-----------+----------------------------+ ``` 而這 64 個位元的前綴,底下又細分為不同的欄位,作為不同階層的網路供應商或網段的分類依據。~~多級 page table:First time?~~。每一級可能由不同的供應商分配(可以參考 [Subnetting IPv6 Addresses](https://youtu.be/UIGVPvxnCtk) 這個影片中的解釋)所以有可能會像下面這樣: ![](https://i.imgur.com/OnpCvWj.png) ## 前 64 位元 --- Network Prefix ### Global Routing Prefix (48 位元) 在目前的狀況中,每一個 Global Unicast Address 前三個位元恰好都是 `001`, 也就是一定會是一個屬於 `2000::/3` 的位址。也就是說:目前的 Global Unicast Address 壹定會具有以下的形式: ``` An example of the resulting format of global unicast address under the 2000::/3 prefix that is currently being delegated by the IANA and consistent with the recommendations in RFC 3177 is: | 3 | 45 bits | 16 bits | 64 bits | +---+---------------------+-----------+----------------------------+ |001|global routing prefix| subnet ID | interface ID | +---+---------------------+-----------+----------------------------+ ``` 雖然現況如此,但實際上根據 [RFC3587](https://datatracker.ietf.org/doc/html/rfc3587),這件事情在日後不一定會繼續成立: ``` RFC 2374 was the definition of addresses for Format Prefix 001 (2000::/3) which is formally made historic by this document. Even though currently only 2000::/3 is being delegated by the IANA, implementations should not make any assumptions about 2000::/3 being special. In the future, the IANA might be directed to delegate currently unassigned portions of the IPv6 address space for the purpose of Global Unicast as well. ``` ### Subnet Mask (16 位元) IANA 分配完前 48 位元的部分之後,整個 global routing prefix 中剩下的 16 位元則可以給使用者自行決定該怎麼規劃 subnet。 ## Interface ID (64 位元)