I am "playing" around with the DNS update script from the Wiki
(https://wiki.samba.org/index.php/Configure_DHCP_to_update_DNS_records_with_BIND9)
and made a "few" changes, which I think could be important.
1. the script dhcp-dyndns.sh should give back the control to dhcpd as
soon as possible; therefore I am using a second bash-script (dyndns.sh)
to fork of the main script with following context:
NOTE: i have both in /etc/dhcp/bin/
#!/bin/bash
(setsid ${0%/*}/dhcp-dyndns.sh $@ 2>&1 & disown)
exit 0
2. changes in dhcpd.conf.main
######Samba##################################################################################
on commit {
set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
set noName = concat("dhcp-", ClientIP);
set ClientDHCID = binary-to-ascii(16, 8, ":",
substring(hardware,1,6));
set ClientName = pick-first-value(config-option server.ddns-hostname,
option host-name, config-option-host-name, client-name, noName);
#log(concat("Commit: IP: ", ClientIP, " DHCID: ",
ClientDHCID, " Name:
", ClientName));
execute("/etc/dhcp/bin/dyndns.sh", "commit", ClientIP,
ClientDHCID,
ClientName);
}
on release {
#log(concat("Release: IP: ", ClientIP, " DHCID: ",
ClientDHCID, " Name:
", ClientName));
execute("/etc/dhcp/bin/dyndns.sh", "release", ClientIP,
ClientDHCID,
ClientName);
}
on expiry {
#log(concat("Expiry: IP: ", ClientIP, " DHCID: ",
ClientDHCID, " Name:
", ClientName));
execute("/etc/dhcp/bin/dyndns.sh", "expiry", ClientIP,
ClientDHCID,
ClientName);
}
#####Samba###################################################################################
. mostly cosmetic in on-commit to shorten it; the ddns-hostname (first
in ClientName) is important for me, because I am manipulating some
client names, like Samsung TVs, with a stupid fixed name: localhost
. the on release and expiry should not try to change the data from the
lease file, which is contra-productive......all the data set in "on
commit" is delivered automatically and can't be extracted from the not
existing dhcpoffer
. execute: first parameter is my "fork-shell script", the second one I
changed from add/delete to on - xxx, to see when a client releases his
lease or to see if dhcpd is kicking him out.
. the writing to the log is commented-out, because you get, with
execute, 5 lines with the same information.
3. due to the above changes also the dhcp-dyndns.sh is changed and there
I changed a lot, because I tried to ask samba itself for all the
parameters? and DNS data. For my tests I added also a function to leave
"doublettes"? like LAN and WLAN with two IPs and the same name and
there
is still my full debugging code in it.
. I didn't touched the Add_macAddress part, because I don't need it.
. Before my changes I had massive CNF entries (failover dhcp setup), but
nowadays I get only one (in every zone) per new client and afterwards
none. My experiment with this entries have shown, that you can list them
with samba-tool, but you can't delete them with it. (I believe that the
line break in the name (windows style with carriage return) is getting
lost, before it arrives the actual delete function)
. One "short coming" is still existing in my script: changing the
subnet
for leases is not deleting the old PTR record, because I can't list the
full rev zone. eg.: 168.192.in-addr.arpa, change from 1.0 to 1.1 leaves
the 1.0 record and I would have to check first in which subnets records
are available and query than all subnets for this record. Normally dhcpd
should kick it after expiry of the lease, but I have a few test-records
left, which my check function is not grabbing.
BTW: I am running samba 4.9.5 at the moment (DC2 was upgraded yesterday
to 4.12.3) For test purposes you can add an (in bind9) existing zone
with RSAT, but bind doesn't survive a restart with it ;-) Therefore I
could check my script with all 3 different zone sizes at once, but I
don't have a busy server.
450 lines are to much for this email, therefore I linked it.
https://1drv.ms/u/s!AtKwcFU5bIBMhzVibxfJsHjygokd?e=cHeim6
NOT FOR PRODUCTION.........pre-Alpha version!!!
Mani