I was working on a project for work on how to log host declarations in DHCP. In your /etc/dhcpd.conf file you may have something like:
host TestPC001 {
hardware ethernet d0:50:56:ac:74:71;
fixed-address 208.x.x.75;
}
For logging purposes if you wanted to see which host got what IP when, this will be a good way to do it. Assuming your dhcpd.conf file is generated dynamically via 3rd party software like NetReg for example. All you will need to do is add the following code in your DHCP file:
if known {
log (info, concat ("HOSTNAME: ", host-decl-name, " on ",binary-to-ascii (10, 8, ".", leased-address)," at ", binary-to-ascii (16, 8, ":", substring (hardware, 1, 6))));
}
It will log to the DHCP Log file as information for hostname by using their host declaration, their lease address and finally their hardware ethernet address.
The log file before the change (timestamps removed):
DHCPDISCOVER from d0:50:56:ac:74:71 via eth0
DHCPOFFER on 208.x.x.75 to d0:50:56:ac:74:71 via eth0
DHCPREQUEST for 208.x.x.75 (172.18.1.2) from d0:50:56:ac:74:71 via eth0
DHCPACK on 208.x.x.75 to d0:50:56:ac:74:71 via eth0
The log file after adding the function:
HOSTNAME: TestPC001 on 208.x.x.75 at d0:50:56:ac:74:71
DHCPDISCOVER from d0:50:56:ac:74:71 via eth0
DHCPOFFER on 208.x.x.75 to d0:50:56:ac:74:71 via eth0
DHCPREQUEST for 208.x.x.75 (172.18.1.2) from d0:50:56:ac:74:71 via eth0
DHCPACK on 208.x.x.75 to d0:50:56:ac:74:71 via eth0
Tags: DHCP, Logging