Linux – Isc-Dhcpserver static DHCP missing client-hostname

dhcpdhostnamelinuxUbuntu

I got a strange problem with my isc-dhcpserver (Ubuntu 16.04).

When clients are requesting from the server, I can see the following output in /var/log/syslog :

Jun 21 21:41:25 drake dhcpd[265]: DHCPREQUEST for 192.168.0.113 (192.168.0.254) from ea:25:63:d9:6c:10 (webdev) via eth1
Jun 21 21:41:25 drake dhcpd[265]: DHCPACK on 192.168.0.113 to ea:25:63:d9:6c:10 (webdev) via eth1

/var/lib/dhcp/dhcpd.leases looks like this for this lease:

lease 192.168.0.113 {
  starts 3 2017/06/21 19:41:25;
  ends 4 2017/06/22 01:41:25;
  cltt 3 2017/06/21 19:41:25;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet ea:25:63:d9:6c:10;
  client-hostname "webdev";

Now let's modify this to be static DHCP:
/etc/dhcp/dhcpd.conf:

host webdev {
        hardware ethernet ea:25:63:d9:6c:10;
        fixed-address 192.168.0.220;
}

Output from /var/log/syslog with missing client-hostname:

Jun 21 22:37:37 drake dhcpd[1627]: DHCPDISCOVER from ea:25:63:d9:6c:10 via eth1
Jun 21 22:37:37 drake dhcpd[1627]: DHCPOFFER on 192.168.0.220 to ea:25:63:d9:6c:10 via eth1
Jun 21 22:37:37 drake dhcpd[1627]: DHCPREQUEST for 192.168.0.220 (192.168.0.254) from ea:25:63:d9:6c:10 via eth1
Jun 21 22:37:37 drake dhcpd[1627]: DHCPACK on 192.168.0.220 to ea:25:63:d9:6c:10 via eth1

Is there any way to make the dhcp-server show the client-hostname in the logfile even if the mac-address is linked to a static IP?

I really think I have done this before…
As far as I can remember, this worked fine on my old Slackware-server back in the days.

The server running isc-dhcpserver is running Ubuntu server 16.04 with the latest updates applied.

Best Answer

Try to use log function. I found example at ISC mailing lists: Static clients: how log hostnames and create lease entries? Add to global section of dhcpd config file:

on commit {
  if (static){set isst = "static";} else {set isst = "dynamic";}
  log (info, concat ("COMMIT IP,", binary-to-ascii (10,8,".",leased-address),
    ",MAC,", suffix (concat ("0", substring(binary-to-ascii (16, 8, ":",hardware), 2, 17)),17),
    ",hostname,", option host-name,
    ",host-decl-name,", pick-first-value(host-decl-name, "(none)"),
    ",dhcp-client-identifier,",pick-first-value(binary-to-ascii(16,8,"",option dhcp-client-identifier),"(none)"),
    ",vendor-class-identifier,", pick-first-value(option vendor-class-identifier, "(none)"),
    ",agent.remote,", pick-first-value(option agent.remote-id, "(none)"),
    ",agent.circuit,", pick-first-value(option agent.circuit-id, "(none)"),
    ",leasetime,", binary-to-ascii (10,32,"",encode-int (lease-time,32)),
    ",asstype,", isst)
  );
}

But dhcp-client must send in DHCPREQUEST or DHCPDISCOVER its client-hostname as option 12. Not all dhcp-clients do it by default.

Related Topic