Isc-Dhcpserver 静态 DHCP 缺少客户端主机名

Isc-Dhcpserver 静态 DHCP 缺少客户端主机名

我的 isc-dhcpserver(Ubuntu 16.04)遇到了一个奇怪的问题。

当客户端向服务器发出请求时,我可以在 /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/dh​​cp/dhcpd.leases 如下所示:

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";

现在让我们将其修改为静态 DHCP:/etc/dhcp/dhcpd.conf:

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

/var/log/syslog 的输出缺少客户端主机名:

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

有什么方法可以让 dhcp 服务器在日志文件中显示客户端主机名,即使 mac 地址链接到静态 IP?

我真的认为我以前做过这个...据我所记得,这在我的旧 Slackware 服务器上运行良好。

运行 isc-dhcpserver 的服务器正在运行 Ubuntu server 16.04,并应用了最新更新。

答案1

尝试使用日志函数。我找到了示例ISC 邮件列表:静态客户端:如何记录主机名和创建租约条目? 添加到 dhcpd 配置文件的全局部分:

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)
  );
}

但是 dhcp-client 必须在 DHCPREQUEST 或 DHCPDISCOVER 中发送其客户端主机名作为选项 12。并非所有 dhcp-client 都默认执行此操作。

相关内容