on (commit|expiry|release) events

Brett @Google brett.maxfield at gmail.com
Sat Jan 4 02:38:45 UTC 2014


Hello,

I have been investigating /learning how to use on (commit|expiry|release)
events in dhcpd.

As a starting point I defined the following in dhcpd.conf (in the global
scope) :

on commit {
log(info, concat("commit", " ", binary-to-ascii(10, 8, ".",
leased-address), " ", concat ( 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)), " ", "'",
(option agent.circuit-id), "'"));
}

on expiry {
log(info, concat("expiry", " ", binary-to-ascii(10, 8, ".",
leased-address)));
}

on release {
log(info, concat("release", " ", binary-to-ascii(10, 8, ".",
leased-address)));
}

This should just log the events and ips / macs, and not do anything else.

When i do a "ipconfig /release" on a windows dhcp client i can see :

Jan  4 12:09:38 dns dhcpd: expiry 192.168.0.239
Jan  4 12:09:38 dns dhcpd: DHCPRELEASE of 192.168.0.239 from
00:19:d2:45:73:2d (xplaptop) via em0 (found)
Jan  4 12:09:38 dns dhcpd: Removed forward map from xplaptop.example.net to
192.168.0.239
Jan  4 12:09:38 dns dhcpd: Removed reverse map on 239.0.168.192.in-addr.arpa

When i do a "ipconfig /renew" on the windows dhcp client, i get :

Jan  4 12:12:10 dns dhcpd: DHCPDISCOVER from 00:19:d2:45:73:2d via em0
Jan  4 12:12:11 dns dhcpd: DHCPOFFER on 192.168.0.239 to 00:19:d2:45:73:2d
(xplaptop) via em0
Jan  4 12:12:11 dns dhcpd: DHCPREQUEST for 192.168.0.239 (192.168.0.252)
from 00:19:d2:45:73:2d (xplaptop) via em0
Jan  4 12:12:11 dns dhcpd: DHCPACK on 192.168.0.239 to 00:19:d2:45:73:2d
(xplaptop) via em0
Jan  4 12:12:11 dns dhcpd: Added new forward map from
xplaptop.example.netto 192.168.0.239
Jan  4 12:12:11 dns dhcpd: Added reverse map from
239.0.168.192.in-addr.arpa to xplaptop.example.net

Note there is no logged "commit" event in this case, but the DDNS still
seems to work ?

The doco says that you should not use events when you are doing dynamic dns
updates as it will break the dynamic updates, which you can see from the
logs above i am. But i am seeing an expiry event, when i would have
expected a release event rather than an expiry event.

My long term goal was to do something like :

on commit {
    set option host-name = pick-first-value(
        option fqdn.hostname,
        option host-name,
        <client provided host name>,
        binary-to-ascii(10, 8, "-", leased-address));
}

Meaning to use the configured hostname, and if none, make one that is the
allocated ip with the dots replaced with dashes.. as if the client does not
provide a client name, and they are an unknown dhcp requester (there is no
hardware address matching it to a host entry) and there is no name provided
by the client, then it would provide some default client name, that DNS can
still use (even if not descriptive).

Otherwise if the client does not provide a dhcp client name, the dns is not
updated (as there is no name to put in the DNS, do that is probably a
reasonable thing)

If this will indeed break DDNS updates (say if i put my events in a zone,
and not as globals), is there a way to call the DDNS internal code after i
have created the default client name, if one was not provided ? Or can
global scripts be made to work also, when a zone has DDNS enabled ?

Any thoughts are welcome..

Cheers
Brett
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20140104/c215fe55/attachment.html>


More information about the dhcp-users mailing list