Ubuntu – DHCP: Logging host declarations in log file

dhcphostsisc-dhcploggingUbuntu

I am currently running ISC-DHCP server v3 on Ubuntu 8.04. What I am trying to do is log Who got what IP address when.

Currently in the DHCP log file you can see the following:

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

I would like to get to the point where I see this or something simular:

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 (TestPC001) via eth0

I need to log the host who got the IP address when (the log file has time stamps but I removed them for this post) for historical purposes.

In my dhcpd.conf file I have the following host declaration:

host TestPC001 {
     hardware ethernet d0:50:56:ac:74:71;
     fixed-address 208.x.x.75;
}

If anyone knows how to do this with DHCP3 that would be great, I am open to suggestions on 3rd party apps that will do this. One thing to note, the dhcpd.conf file is generated dynamically using a 3rd party app that does RADIUS, so the host declarations can and will change so I can not simply just look at the file if there is a problem with someone on the network and get their name.

Best Answer

I have figured it out.

Adding the following to the dhcpd.conf 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)))); 
}  

Will result in (I have removed timestamps for neatness):

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
Related Topic