[Samba] isc-dhcp dynamic update problem

me at tdiehl.org me at tdiehl.org
Mon Oct 5 15:07:00 UTC 2020


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



More information about the samba mailing list