DHCP固定割当とかClientIdentifierとかRFC2131とか
とりあえずIPv4の話。
概要
RFC2131ことDHCPには、クライアント識別子を宣言するClientIdentifierというオプションが定義されている
原型となったBOOTPにはない
これがない場合は、chaddr=DHCPプロトコルのコミュニケーションに使うMACアドレスを使う。使っていた。
DHCPクライアントのMACアドレスと、ホストの識別子は別であってしかるべきでは?という話らしい
曰く、NICが別マシンに移植された時に同じIPアドレスが振り出されたら混乱するでしょ?
曰く、ハードウェアが変わっても同じホストに同じIPアドレスが残ってくれたら便利でしょ?
DHCPサーバーはクライアントの識別子として、ClientIdentifierがあればそれを使わなければならないとされている
A DHCP server needs to use some unique identifier to associate a client with its lease. The client MAY choose to explicitly provide the identifier through the 'client identifier' option. If the client supplies a 'client identifier', the client MUST use the same 'client identifier' in all subsequent messages, and the server MUST use that identifier to identify the client. If the client does not provide a 'client identifier' option, the server MUST use the contents of the 'chaddr' field to identify the client.
のちにRFC4361で、DHCPv6との相互運用性のため、ClientIdentifierを必須にし、chaddrを識別子に使ってはならないと変更された この場合 hardware type は255となる。元々ハードウェアアドレス以外の時に使われていた 0 と異なることに注意。
かくして、DHCP固定割当みたいなことをしたい時にもほしい識別子に、以下のようなバリエーションが生まれている
ClientIdentifierなしのパターン(chaddrを見るしかない)
ClientIdentifierにMACアドレスを入れるパターン
ClientIdentifierにその他の安定した識別子を入れるパターン
各実装
凡例: cid-none, cid-mac, cid-duid, cid-raw
Windows: cid-mac
Linux:
netplan: レンダラー+設定次第(networkd or NetworkManager)
networkdの場合、以下の設定も使える
dhcp-identifier: duid or 省略 で cid-duid
dhcp-identifier: mac で cid-mac
設定確認: netplan get all で見る
NetworkManager: 設定+バックエンド次第(builtin / dhclient / dhcpcd)
ipv4.dhcp-client-id を 01:<mac> や mac にしたらcid-mac
ipv4.dhcp-client-id を duid にしたらcid-duid
ipv4.dhcp-client-id を省略したらグローバルデフォルト or バックエンド次第
設定確認: nmcli con show <name> で ipv4.dhcp-client-id の設定値を見る
dhcpcd: /etc/dhcpcd.conf による
clientid cid-mac
duid cid-duid?
省略 cid-none?
dhclient: /etc/dhclient.conf による
send dhcp-client-identitifer 1:<mac> cid-mac
send dhcp-client-identitifer "blahblah" cid-raw
省略 cid-none?
networkd: /etc/systemd/network/ 下の設定ファイルによる
ClientIdentifier=duid or 省略 で cid-duid
ClientIdentifier=mac で cid-mac
(cid-noneの方法はない気がする)
tsharkで見たClientIdentifier
code:tshark.txt
type=1 MACアドレスの場合
Option: (61) Client identifier
Length: 7
Hardware type: Ethernet (0x01)
Client MAC address: RealtekU_ba:45:66 (52:54:00:ba:45:66)
type=255 DUIDの場合
Option: (61) Client identifier
Length: 19
IAID: 2b506735
DUID Type: assigned by vendor based on Enterprise number (2)
Enterprise-number: Tom Gundersen (systemd) (43793)
Identifier: d0c12a74052d4010
type=0 その他識別子の場合
Option: (61) Client identifier
Length: 9
Type: 0
Client Identifier: hogehoge
type=16 適当なtypeを指定した場合
Option: (61) Client identifier
Length: 6
YAMAHAルーター
dhcp server rfc2131 compliant が on もしくは use-clientid が含められている場合は、clientidが優先して使われる
chaddrのエントリがあってもclientidのエントリがなければ適用されない
dhcp server rfc2131 compliant が off もしくは use-clientid が除外されている場合は、chaddrのみが使われる
clientidを使った dhcp scope bind はできないし、切り替えた時に既存のエントリも削除される