I would like to classify DHCP clients to be served an IP address from a pool defined in a subnet declaration in an ISC DHCPD's config file, and update the DNS server with that information.
Using option "dhcp-client-identifier" for clients to send the same class identifier wouldn't work, because a subsequent IP address request (from a different client) with the same identifier would tell the DHCP server that the previous client connected, instead of the latter, thus (trying to) update the DNS server with the new IP, loosing the entry for the previous client.
Resources I found on the Internet so far only talk about messing with existing options (usually vendor extensions) but nothing that would tell me what to do.
What I am thinking of doing is this:
- Define a custom option
- Configure client to send the class with an appropriate value
- Define a client class on the server based on that option's value
- Serve IP address according to the class
My approach is this:
DHCP Server, in /etc/dhcp/dhcpd.conf:
option foo code 224 = text; # code 224 - 250 is defined as local class range
...
class "myclass" {
match if option foo ~= "value";
}
...
subnet xxx.xxx.xxx.xxx netmask 255.255.255.0 {
pool {
...
allow members of "myclass";
deny known-clients;
}
}
The DHCP server seem happy with at least the syntax:
root@ns:/home/michel# dhcpd -t -cf /etc/dhcp/dhcpd.conf.test
Internet Systems Consortium DHCP Server 4.3.1
Copyright 2004-2014 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Config file: /etc/dhcp/dhcpd.conf.test
Database file: /var/lib/dhcp/dhcpd.leases
PID file: /var/run/dhcpd.pid
root@ns:/home/michel#
(Don't kill me over being root - I did a "sudo bash" for convenience)
DHCP client, in /etc/dhcp/dhclient.conf:
# This is what I'd like the client to be able to send to make this all work
send foo "42";
I hope I am on the right track, but I think I am missing something here...
- DHCP server: isc-dhcp-server/oldstable,now 4.3.1-6+deb8u2 armhf
- DHCP clients: isc-dhcp-client/xenial-updates,now 4.3.3-5ubuntu12.7 amd64
Thanks, Michel