IPv6アドレス
Private network IPv6
RFC 4193
RFC 4193: Unique Local IPv6 Unicast Addresses
3. Local IPv6 Unicast Addresses
3.1. Format
The Local IPv6 addresses are created using a pseudo-randomly
allocated global ID. They have the following format:
| 7 bits |1| 40 bits | 16 bits | 64 bits |
+--------+-+------------+-----------+----------------------------+
| Prefix |L| Global ID | Subnet ID | Interface ID |
+--------+-+------------+-----------+----------------------------+
Where:
Prefix FC00::/7 prefix to identify Local IPv6 unicast
addresses.
L Set to 1 if the prefix is locally assigned.
Set to 0 may be defined in the future. See
Section 3.2 for additional information.
Global ID 40-bit global identifier used to create a
globally unique prefix. See Section 3.2 for
additional information.
Subnet ID 16-bit Subnet ID is an identifier of a subnet
within the site.
Interface ID 64-bit Interface ID as defined in [ADDARCH].
ローカルIPv6アドレスの作成例
Prefix
とL
の箇所はローカルIPの場合 FD
となります。これにGlobal ID
の箇所の40ビット(5バイト)を組合せてIPv6
のアドレス空間を定義します。
この40ビットは、タイムスタンプとマシンIDを組合せた文字列をSHA-1アルゴリズムによりハッシュした値から抜出します。
タイムスタンプ
$ date +%s%N
1667828524739484659
ホストマシンID
$ cat /var/lib/dbus/machine-id
610cef4946ed46da8f71dba9d66c67fb
タイムスタンプにホストマシンIDを追加してハッシュ(16進数x40桁)
$ printf 1667828524739484659610cef4946ed46da8f71dba9d66c67fb | sha1sum
ac4bebe3c52239cffc4909223ac08d16286349e8 -
必要なのは40ビット(5バイト)なので、ここから下位の40ビット(10桁分)を抜出します。
16286349e8
これをPrefix
と組合せ、IPv6
のローカルIPアドレス空間を定義します。サブネットを固定するため /64
を追加します。
fd16:2863:49e8::/64