debugging on the DHCP server

Meike Stone meike.stone at googlemail.com
Mon Jul 14 10:09:37 UTC 2014


Hello,

is it possible, to log each DHCP transaction for debugging with
options (of my choice) in athe logfile?

All possible Clientsmessages
- DHCPDISCOVER
- DHCPREQUEST
- DHCPDECLINE
- DHCPRELEASE
- DHCPINFORM

and the Serveranswers
- DHCPOFFER
- DHCPACK
- DHCPNAK

Additional (as cherry on the cake), I would be pleased, If I could do
a Filter to a dedicated Client MAC address.


I tried something like this (but it is not really satisfying ...):

======================================================
log-facility local4;


        set myVCI       = pick ( option vendor-class-identifier , "no
vendor-id");
        set myCI        = pick ( option user-class , "no user-class
identifier");
        set myMsgType   = binary-to-ascii (16, 8, ".",option dhcp-message-type);
        set myMAC       = substring (binary-to-ascii (16, 8, ":",
hardware), 2, 50);
        set myLeaseTime = binary-to-ascii (10, 32, ".",
encode-int(lease-time, 32));
        set myTID       = binary-to-ascii (16, 32, "",(packet(4, 4)));
        set myIP        = binary-to-ascii (10, 8, ".", leased-address);
        set myHostname  = pick (option fqdn.hostname, option host-name,
                concat ("dhcp-",
                suffix (concat ("0", binary-to-ascii (16, 8, "",
substring(hardware, 1, 1))),2),
                suffix (concat ("0", binary-to-ascii (16, 8, "",
substring(hardware, 2, 1))),2),
                suffix (concat ("0", binary-to-ascii (16, 8, "",
substring(hardware, 3, 1))),2),
                suffix (concat ("0", binary-to-ascii (16, 8, "",
substring(hardware, 4, 1))),2),
                suffix (concat ("0", binary-to-ascii (16, 8, "",
substring(hardware, 5, 1))),2),
                suffix (concat ("0", binary-to-ascii (16, 8, "",
substring(hardware, 6, 1))),2)
                )
        );

        log (info, concat ("Client: MAC: " , myMAC, " | TID: 0x",
myTID, " | MSG-Type: ", myMsgType , " | Hostname: " , myHostname ," |
IP: ", myIP , " | LT remains: " , myLeaseTime,  " | Vendor-ID: " ,
myVCI, " | ClassIdendifier: ", myCI));
======================================================

or:

======================================================

on expiry {
 ...
}

on commit {
 ...
}


on release {
 ...
}

======================================================


Thanks a lot Meike!


More information about the dhcp-users mailing list