<div dir="ltr"><div><div><div><div><div><div>Hello,<br><br></div>I have been investigating /learning how to use on (commit|expiry|release) events in dhcpd.<br><br></div>As a starting point I defined the following in dhcpd.conf (in the global scope) :<br>
<br>on commit {<br>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), "'"));<br>
}<br><br>on expiry {<br>log(info, concat("expiry", " ", binary-to-ascii(10, 8, ".", leased-address)));<br>}<br><br>on release {<br>log(info, concat("release", " ", binary-to-ascii(10, 8, ".", leased-address)));<br>
}<br><br></div>This should just log the events and ips / macs, and not do anything else.<br><br></div>When i do a "ipconfig /release" on a windows dhcp client i can see :<br><br>Jan  4 12:09:38 dns dhcpd: expiry 192.168.0.239<br>
Jan  4 12:09:38 dns dhcpd: DHCPRELEASE of 192.168.0.239 from 00:19:d2:45:73:2d (xplaptop) via em0 (found)<br>Jan  4 12:09:38 dns dhcpd: Removed forward map from <a href="http://xplaptop.example.net">xplaptop.example.net</a> to 192.168.0.239<br>
Jan  4 12:09:38 dns dhcpd: Removed reverse map on 239.0.168.192.in-addr.arpa<br><br></div>When i do a "ipconfig /renew" on the windows dhcp client, i get :<br><br>Jan  4 12:12:10 dns dhcpd: DHCPDISCOVER from 00:19:d2:45:73:2d via em0<br>
Jan  4 12:12:11 dns dhcpd: DHCPOFFER on 192.168.0.239 to 00:19:d2:45:73:2d (xplaptop) via em0<br>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<br>Jan  4 12:12:11 dns dhcpd: DHCPACK on 192.168.0.239 to 00:19:d2:45:73:2d (xplaptop) via em0<br>
Jan  4 12:12:11 dns dhcpd: Added new forward map from <a href="http://xplaptop.example.net">xplaptop.example.net</a> to 192.168.0.239<br>Jan  4 12:12:11 dns dhcpd: Added reverse map from 239.0.168.192.in-addr.arpa to <a href="http://xplaptop.example.net">xplaptop.example.net</a><br>
<br></div>Note there is no logged "commit" event in this case, but the DDNS still seems to work ?<br clear="all"><div><div><div><div><div><div><div><br></div><div>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. <br>
<br></div><div>My long term goal was to do something like :<br><br>on commit {<br>    set option host-name = pick-first-value(<br>        option fqdn.hostname,<br>        option host-name,<br></div><div>        <client provided host name>,<br>
</div><div>        binary-to-ascii(10, 8, "-", leased-address));<br>}<br><br></div><div>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).<br>
<br></div><div>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)<br><br></div><div>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 ?<br>
</div><div><br></div><div>Any thoughts are welcome..<br></div><div><br></div><div>Cheers<br></div><div>Brett<br></div></div></div></div></div></div></div></div>