Hi, I have a buster system configured as a DC running 4.11.13 from Louis's repo. I am trying to get https://wiki.samba.org/index.php/Configure_DHCP_to_update_DNS_records_with_BIND9 working. Mostly it seems to work but there seems to be a problem with what dhcpd writes into the leases file in the "on release" stanza. When dhcpd writes the On Release stanza I get something like the following: lease 172.30.1.40 { starts 0 2020/10/04 22:08:55; ends 0 2020/10/04 22:38:55; tstp 0 2020/10/04 22:38:55; cltt 0 2020/10/04 22:08:55; binding state active; next binding state free; rewind binding state free; hardware ethernet c8:1f:66:08:dd:49; uid "\001\310\037f\010\335I"; set vendor-class-identifier = "MSFT 5.0"; set noname = "dhcp-172-30-1-40"; set ClientIP = "172.30.1.40"; set ClientDHCID = "c8:1f:66:08:dd:49"; set ClientName = "MB-DISPATCH-20"; client-hostname "MB-DISPATCH-20"; on expiry { set ClientIP binary-to-ascii (10, 8, ".", leased-address) ; log (debug, concat ("Expired: IP: ", ClientIP)); execute ("/usr/local/bin/dhcp-dyndns.sh", "delete", ClientIP, "", "0"); } on release { set ClientIP binary-to-ascii (10, 8, ".", leased-address) ; set ClientDHCID concat (concat (concat (concat (concat (concat (concat (concat (concat ( 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 )) ; log (debug, concat ("Release: IP: ", ClientIP)); execute ("/usr/local/bin/dhcp-dyndns.sh", "delete", ClientIP, ClientDHCID); } } I have the following in the dhcpd.conf file: on commit { set noname = concat("dhcp-", binary-to-ascii(10, 8, "-", leased-address)); set ClientIP = binary-to-ascii(10, 8, ".", leased-address); set ClientDHCID = 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) ); set ClientName = pick-first-value(option host-name, config-option-host-name, client-name, noname); log(concat("Commit: IP: ", ClientIP, " DHCID: ", ClientDHCID, " Name: ", ClientName)); execute("/usr/local/bin/dhcp-dyndns.sh", "add", ClientIP, ClientDHCID, ClientName); } on release { set ClientIP = binary-to-ascii(10, 8, ".", leased-address); set ClientDHCID = 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) ); log(concat("Release: IP: ", ClientIP)); execute("/usr/local/bin/dhcp-dyndns.sh", "delete", ClientIP, ClientDHCID); } on expiry { set ClientIP = binary-to-ascii(10, 8, ".", leased-address); # cannot get a ClientMac here, apparently this only works when actually receiving a packet log(concat("Expired: IP: ", ClientIP)); # cannot get a ClientName here, for some reason that always fails execute("/usr/local/bin/dhcp-dyndns.sh", "delete", ClientIP, "", "0"); } Can someone see what I am doing wrong? Is there a way to debug this? Regards, -- Tom me at tdiehl.org
Dear Tom nothing wrong, except that there is unnecessary data written, which will not be used. try this in your dhcp.conf on commit { set noname = concat("dhcp-", binary-to-ascii(10, 8, "-", leased-address)); set ClientIP = binary-to-ascii(10, 8, ".", leased-address); set ClientDHCID = binary-to-ascii(16, 8, ":", substring(hardware,1,6)); set ClientName = pick-first-value(option host-name, config-option-host-name, client-name, noname); log(concat("Commit: IP: ", ClientIP, " DHCID: ", ClientDHCID, " Name: ", ClientName)); execute("/usr/local/bin/dhcp-dyndns.sh", "add", ClientIP, ClientDHCID, ClientName); } on release { log(concat("Release: IP: ", ClientIP)); execute("/usr/local/bin/dhcp-dyndns.sh", "delete", ClientIP, ClientDHCID, ClientName); } on expiry { log(concat("Release: IP: ", ClientIP)); execute("/usr/local/bin/dhcp-dyndns.sh", "delete", ClientIP, ClientDHCID, ClientName); } br Mani On 05.10.2020 17:07, Tom Diehl via samba wrote:> on commit { > set noname = concat("dhcp-", binary-to-ascii(10, 8, "-", > leased-address)); > set ClientIP = binary-to-ascii(10, 8, ".", leased-address); > set ClientDHCID = 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) > ); > set ClientName = pick-first-value(option host-name, > config-option-host-name, client-name, noname); > log(concat("Commit: IP: ", ClientIP, " DHCID: ", ClientDHCID, " Name: > ", ClientName)); > execute("/usr/local/bin/dhcp-dyndns.sh", "add", ClientIP, ClientDHCID, > ClientName); > } > > on release { > set ClientIP = binary-to-ascii(10, 8, ".", leased-address); > set ClientDHCID = 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) > ); > log(concat("Release: IP: ", ClientIP)); > execute("/usr/local/bin/dhcp-dyndns.sh", "delete", ClientIP, > ClientDHCID); > } > > on expiry { > set ClientIP = binary-to-ascii(10, 8, ".", leased-address); > # cannot get a ClientMac here, apparently this only works when > actually receiving a packet > log(concat("Expired: IP: ", ClientIP)); > # cannot get a ClientName here, for some reason that always fails > execute("/usr/local/bin/dhcp-dyndns.sh", "delete", ClientIP, "", "0"); > }
Hi Mani, Thanks for the response. On Mon, 5 Oct 2020, Mani Wieser via samba wrote:> Dear Tom > > Nothing wrong, except that there is unnecessary data written, which will not > be used.Seems reasonable but ... If the below is all that is needed, why does the Wiki article have the extra lines in it? Besides cluttering up the leases file with unnecessary data, what purpose do the extra lines serve? What am I missing? Regards, -- Tom me at tdiehl.org> > try this in your dhcp.conf > > on commit { > set noname = concat("dhcp-", binary-to-ascii(10, 8, "-", leased-address)); > set ClientIP = binary-to-ascii(10, 8, ".", leased-address); > set ClientDHCID = binary-to-ascii(16, 8, ":", substring(hardware,1,6)); > set ClientName = pick-first-value(option host-name, config-option-host-name, > client-name, noname); > log(concat("Commit: IP: ", ClientIP, " DHCID: ", ClientDHCID, " Name: ", > ClientName)); > execute("/usr/local/bin/dhcp-dyndns.sh", "add", ClientIP, ClientDHCID, > ClientName); > } > > on release { > log(concat("Release: IP: ", ClientIP)); > execute("/usr/local/bin/dhcp-dyndns.sh", "delete", ClientIP, ClientDHCID, > ClientName); > } > > on expiry { > log(concat("Release: IP: ", ClientIP)); > execute("/usr/local/bin/dhcp-dyndns.sh", "delete", ClientIP, ClientDHCID, > ClientName); > } > > br > > Mani > > > On 05.10.2020 17:07, Tom Diehl via samba wrote: >> on commit { >> set noname = concat("dhcp-", binary-to-ascii(10, 8, "-", leased-address)); >> set ClientIP = binary-to-ascii(10, 8, ".", leased-address); >> set ClientDHCID = 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) >> ) ; >> set ClientName = pick-first-value(option host-name, >> config-option-host-name, client-name, noname); >> log(concat("Commit: IP: ", ClientIP, " DHCID: ", ClientDHCID, " Name: ", >> ClientName)); >> execute("/usr/local/bin/dhcp-dyndns.sh", "add", ClientIP, ClientDHCID, >> ClientName); >> } >> >> on release { >> set ClientIP = binary-to-ascii(10, 8, ".", leased-address); >> set ClientDHCID = 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) >> ) ; >> log(concat("Release: IP: ", ClientIP)); >> execute("/usr/local/bin/dhcp-dyndns.sh", "delete", ClientIP, ClientDHCID); >> } >> >> on expiry { >> set ClientIP = binary-to-ascii(10, 8, ".", leased-address); >> # cannot get a ClientMac here, apparently this only works when actually >> receiving a packet >> log(concat("Expired: IP: ", ClientIP)); >> # cannot get a ClientName here, for some reason that always fails >> execute("/usr/local/bin/dhcp-dyndns.sh", "delete", ClientIP, "", "0"); >> } > >
Reasonably Related Threads
- Configure DHCP to update DNS records with BIND9
- samba4 bind9_dlz and dhcp
- samba_dnsupdate options: --use-samba-tool vs. --use-nsupdate, and dhcpd dynamic updates
- DDNS with bind9 and isc-dhcp-server
- [Fwd: Re: [Fwd: Re: [Fwd: Re: [Fwd: Re: Samba 4 more complete]]]]