1

Here was answered how to assign an IP by MAC address.
I want DHCPd server to assign IP by UID.

Can i just add record to dhcpd.conf in the same manner? For example:

host example
    {
      uid 00:70:ff:13:2f:34:30;
      fixed-address 192.168.1.30;
    }

Will it work?

Vololodymyr
  • 113
  • 1
  • 5

2 Answers2

1

It is possible by using DUID-UUID.

On the server side it is required to identify the host by option dhcp-client-identifier like below:

host example {
  option dhcp-client-identifier FF:II:II:II:II:00:04:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU;
}

where II are four bytes of IAID and UU are sixteen bytes of UUID, FF and 00:04 are literal bytes at these places.

The part starting with 00:04 with the following 16 UUID bytes is DUID-UUID, as described in RFC6355.

Now, DHCPv4 client needs to construct Identity Association Unique Identifier, which is described in section 6.1 of RFC4361. As DHCPv4 only allows HW address or client id as the keys to distinguish different host is has to choose client id (as HW address has fixed definition). It starts with FF byte which identifies client id as DUID based. This is immediately followed by 4 bytes of IAID (don't ask, I don't know) and then DUID. In case of DUID-UUID it starts with 16 bits of identification (4) and is followed by 16 bytes of UUID. Of course other DUID types (see section 9 of RFC3315) can be used as well.

I usually select 0 or 1 as IAID.

Now, on the client side one needs to define DUID and IAID somewhere. As I use AlmaLinux 8.6 and 9.0 I will show how to do it in NetworkManager.

DUID seems to be an identifier attached to specific system, not necessarily interface, so I will put it in /etc/NetworkManager/NetworkManager.conf file in [connection] section:

[connection]
ipv4.dhcp-client-id=ipv6-duid
ipv6.dhcp-duid=00:04:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU

The first line indicates that DHCPv4 client id will be based on ipv6-duid, the second defines system wide, default, ipv6.dhcp-duid.

We also need ipv4.dhcp-iaid, which goes into the same section:

[connection]
ipv4.dhcp-iaid=II:II:II:II
ipv4.dhcp-client-id=ipv6-duid
ipv6.dhcp-duid=00:04:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU:UU

NOTE: I am not sure about exact format of ipv4.dhcp-iaid as I usually put single 0 or 1 there which matches 00:00:00:00 or 00:00:00:01 on the server side.

These settings can be also specified per connection. See man nm-settings for more information.

And for the last thing, I usually generate my system UUID based on its FQDN as below:

uuidgen --sha1 --namespace @dns --name host.example.org

I hope this helps.

Tomek
  • 3,390
  • 1
  • 16
  • 10
0

AFAIK there are no methods to assign IP's by UID's directly. It's only mentioned in dhcpd.leases manual and it's a optional value that client sends. Not even a whiff in RFC2131 and RFC2132.

You may workaround this by changing the devices' MAC addresses to that UID, if that's an option or dynamically changing the host declarations based on dhcpd.leases UID values and reloading DHCPd configuration.

  • FWIW, I wasn't trying to send the IP by UID (I was trying to send some other info to the hosts based on their UID), but I did manage to send other information by UID by specifically calling it out in the dhcp-client-identifier in dhclient.conf. – Peter Turner Jun 03 '22 at 12:17