IPv6 ULA(唯一本地位址)生成

IPv6 ULA(唯一本地位址)生成

RFC4193 包含用於產生 IPv6 ULA(唯一本機位址)的偽代碼。我是否必須遵循此演算法,或者任意 ULA 是否有效?

   3.2.2. Sample Code for Pseudo-Random Global ID Algorithm

   The algorithm described below is intended to be used for locally
   assigned Global IDs.  In each case the resulting global ID will be
   used in the appropriate prefix as defined in Section 3.2.

     1) Obtain the current time of day in 64-bit NTP format [NTP].

     2) Obtain an EUI-64 identifier from the system running this
        algorithm.  If an EUI-64 does not exist, one can be created from
        a 48-bit MAC address as specified in [ADDARCH].  If an EUI-64
        cannot be obtained or created, a suitably unique identifier,
        local to the node, should be used (e.g., system serial number).

     3) Concatenate the time of day with the system-specific identifier
        in order to create a key.

     4) Compute an SHA-1 digest on the key as specified in [FIPS, SHA1];
        the resulting value is 160 bits.

     5) Use the least significant 40 bits as the Global ID.

     6) Concatenate FC00::/7, the L bit set to 1, and the 40-bit Global
        ID to create a Local IPv6 address prefix.

如果時間不是一個因素,我會更願意。是否可以接受使用連結本地地址(Mac 派生)並替換第一個八位元組以將其轉換為 ULA?

答案1

關於從連結本地地址獲取一些位,並非所有地址都適合這樣做。非MAC派生不會有任何隨機性,fe80::1在某些網路中被用作大家的網關。

從技術上講,不需要該演算法。但 ULA 必須是隨機的。從之前的 3.2.1 節開始:

本機分配的全域 ID 必須使用符合下列條件的偽隨機演算法產生:[隨機的]。 3.2.2 節描述了建議的演算法。重要的是,所有產生全域 ID 的網站都使用功能相似的演算法,以確保具有較高的唯一性機率。

建議的演算法使用常用的原語作為輸入,以確保可靠的唯一性。如果沒有重新定址虛擬機器或網路卡供應商犯了錯誤,其他人可能會擁有相同的 MAC 位址。但產生具有相同 NTP 時間戳記的可能性極小。當然,如果您不想編寫程式碼,您可以找到已經編寫的實作。

如果您使用其他東西,請不要使用純粹基於 MAC 位址的方案。也許從 /dev/random 讀取 40 位元。

相關內容