I have LAN hosts which change their DUID frequently after each boot. It might sound strange but it is because of how the Chinese PXE booting software works. Since all computers share a single immutable disk image, the DUID is generated at boot time using DUID-LLT (Link-Layer address plus Time) so that the DUIDs are different for all computers. And as such, odhcpd assigns multiple different IPv6 addresses to a computer if it reboots after a while.
For example, if the computer pc01 boots up the first time, it is assigned an address 2001::7, and if it reboots 2 hours later, it will get 2001::8 due to DUID change.
Both addresses are registered with dnsmasq DDNS for the same hostname pc01. Only the newest address 2001::8 is valid though. When I try to access the host using its domain name for example ping.exe pc01.lan, dnsmasq returns multiple IPv6 addresses which causes a high chance for my computer to use an invalid old address 2001::7.
To solve the problem, I try to reserve an IPv6 address for pc01:
config host 'pc01'
option name 'pc01'
option duid '00010001298a1193089798ebc801'
option hostid 'f0e8c9cd2c698c4f'
list mac '08:97:98:eb:c8:01'
list mac 'b4:0e:de:d0:49:22'
option ip '192.168.1.34'
option leasetime '12h'
The problem is: DHCPv6 reservation does not work without option duid, while I do not know what DUID the host pc01 uses the next time it boots.
Why does it not work with option mac like DHCPv4 does? Maybe DHCPv6 protocol does not use client's MAC address? And is there anything I can do to workaround this issue?
The whole basic definition of DUID is that it is stable and doest change so if it change at every boot your client have some seriously bad setup or operating system.
DHCPv6 doesn't use MAC, it uses DUID instead.
For a workaround you can set the option to use the same lifetime as in DHCPv4 uci set dhcp.lan.ra_useleasetime=1
and keep a low lease time to force the old IP to be flushed.
By design, IPv6 uses MAC addresses only to control access to shared physical media such as Ethernet or WiFi. This makes DHCPv6 an L3 process instead of L2 as DHCPv4.
Units might contain a permanent globally unique identifying number such as hardware MAC or manufacturer's serial number. The OS should use one of these numbers to create a globally unique hostname and/or DUID which remains consistent per unit. Though really cheap Chinese manufacturers don't bother with OUI MACs or serial numbers.
With both v4 and v6, DHCP addresses can be reserved by hostname as long as each endpoint device sends a hostname which is unique on your network.
Are you mistaken? Is that option for RA or DHCPv6? Currently I am using RA for these hosts and it works well, but dynamic DNS does not work -- RA autoconfigured IPv6 addresses are not registered on dnsmasq. And that's why I want to use DHCPv6 in conjunction with RA.
Right after booting up, the PXE boot agent in the disk image immediately changes the hostname to the correct one (eg: pc01 pc02...). Hence the hostnames are consistent for each PC. I tried and it did not work, however:
The host pc03 does not receive the DHCP lease. According to the user guide, the option name is Optional hostname to assign which is meant to override the hostname provided by the DHCP client inside the DHCP request packet.
Not mistaken. You obviously should not allocate DHCP for more than the RA is valid, as any change in the network settings will render the address acquired from the DHCP useless.
In any case, it is working as expected for me and you could have given it a try instead of writing all this essay.