Sebastian Arcus
2018-Mar-29 14:01 UTC
[Samba] dhcp lease time hardware in script at dhcpd/Bind/Samba wiki page
There seems to be a slight issue with the instructions at the following wiki page: https://wiki.samba.org/index.php/Configure_DHCP_to_update_DNS_records_with_BIND9 The /usr/local/bin/dhcp-dyndns.sh script seems to use a hardwired value for the lease expiry time of 3600 - independent of whatever is configured in dhcpd.conf. With the examples provided, it should work, as the example dhcpd.conf uses 1800 for lease expiry time - so dhcpd will try to renew the lease before it actually expires. However, when I implemented the script, I didn't notice that the lease time is hardwired in the dhcp-dyndns.sh script - so I've set a higher value in dhcpd.conf. This seems to have caused all sorts of strange behaviour, as Bind/samba_dlz were expiring leases and dhcpd wasn't renewing them - thinking they are still valid. Would it be possible to pass the max lease time value from dhcpd.conf to the dhcp-dyndns.sh script somehow? I would have made a suggestion myself, but for the life of me I can't find anywhere on the net a reference of standard variable which can be used in dhcpd.conf. If the above is not possible, maybe a max-lease-time variable should be placed at the top of the dhcp-dyndns.sh script. so that at least it is obvious that this is set again in this script, and not carried over from dhcpd.conf?
Rowland Penny
2018-Mar-29 14:52 UTC
[Samba] dhcp lease time hardware in script at dhcpd/Bind/Samba wiki page
On Thu, 29 Mar 2018 15:01:26 +0100 Sebastian Arcus via samba <samba at lists.samba.org> wrote:> There seems to be a slight issue with the instructions at the > following wiki page: > > https://wiki.samba.org/index.php/Configure_DHCP_to_update_DNS_records_with_BIND9 > > The /usr/local/bin/dhcp-dyndns.sh script seems to use a hardwired > value for the lease expiry time of 3600 - independent of whatever is > configured in dhcpd.conf. With the examples provided, it should work, > as the example dhcpd.conf uses 1800 for lease expiry time - so dhcpd > will try to renew the lease before it actually expires. However, when > I implemented the script, I didn't notice that the lease time is > hardwired in the dhcp-dyndns.sh script - so I've set a higher value > in dhcpd.conf. This seems to have caused all sorts of strange > behaviour, as Bind/samba_dlz were expiring leases and dhcpd wasn't > renewing them - thinking they are still valid. > > Would it be possible to pass the max lease time value from dhcpd.conf > to the dhcp-dyndns.sh script somehow? I would have made a suggestion > myself, but for the life of me I can't find anywhere on the net a > reference of standard variable which can be used in dhcpd.conf. > > If the above is not possible, maybe a max-lease-time variable should > be placed at the top of the dhcp-dyndns.sh script. so that at least > it is obvious that this is set again in this script, and not carried > over from dhcpd.conf? >You could try adding something like this near to the top of dhcp-dyndns.sh: TTL=$(cat /etc/dhcp/dhcpd.conf | grep 'max-lease-time' | awk -F ';' '{print $1}' | awk '{print $NF}') Then replace the '3600' with '$TTL' Rowland
Sebastian Arcus
2018-Mar-29 15:24 UTC
[Samba] dhcp lease time hardware in script at dhcpd/Bind/Samba wiki page
On 29/03/18 15:52, Rowland Penny via samba wrote:> On Thu, 29 Mar 2018 15:01:26 +0100 > Sebastian Arcus via samba <samba at lists.samba.org> wrote: > >> There seems to be a slight issue with the instructions at the >> following wiki page: >> >> https://wiki.samba.org/index.php/Configure_DHCP_to_update_DNS_records_with_BIND9 >> >> The /usr/local/bin/dhcp-dyndns.sh script seems to use a hardwired >> value for the lease expiry time of 3600 - independent of whatever is >> configured in dhcpd.conf. With the examples provided, it should work, >> as the example dhcpd.conf uses 1800 for lease expiry time - so dhcpd >> will try to renew the lease before it actually expires. However, when >> I implemented the script, I didn't notice that the lease time is >> hardwired in the dhcp-dyndns.sh script - so I've set a higher value >> in dhcpd.conf. This seems to have caused all sorts of strange >> behaviour, as Bind/samba_dlz were expiring leases and dhcpd wasn't >> renewing them - thinking they are still valid. >> >> Would it be possible to pass the max lease time value from dhcpd.conf >> to the dhcp-dyndns.sh script somehow? I would have made a suggestion >> myself, but for the life of me I can't find anywhere on the net a >> reference of standard variable which can be used in dhcpd.conf. >> >> If the above is not possible, maybe a max-lease-time variable should >> be placed at the top of the dhcp-dyndns.sh script. so that at least >> it is obvious that this is set again in this script, and not carried >> over from dhcpd.conf? >> > > You could try adding something like this near to the top of > dhcp-dyndns.sh: > > TTL=$(cat /etc/dhcp/dhcpd.conf | grep 'max-lease-time' | awk -F ';' > '{print $1}' | awk '{print $NF}') > > Then replace the '3600' with '$TTL'Thank you for that! I take it there is no corresponding variable, which can be used as an argument in dhcpd.conf when calling dhcp-dyndns.sh? Also, I discovered another typo on the wiki page - which was actually a bit of a pain to track down. On the following line: rzone=$(echo ${ip} | awk -F '.' '{print $3"."$2"."$1".in-addr.arpa"}’) The last quote should be a single quote, but it is actually a backtick. I can report that on Slackware-current with dhcpd 4.4.1, the extra setting suggested to set the rzone is necessary - otherwise Bind tries to use a B class reverse zone instead of a C one and complains that it isn't authoritative for it: updating zone '168.192.IN-ADDR.ARPA/IN': update failed: not authoritative for update zone (NOTAUTH) I have other Slackware servers with dhcpd 4.3.6 and 4.3.4 - and those are happy without the rzone line.
Harry Jede
2018-Mar-29 19:15 UTC
[Samba] dhcp lease time hardware in script at dhcpd/Bind/Samba wiki page
Hi Rowland,> You could try adding something like this near to the top of > dhcp-dyndns.sh: > > TTL=$(cat /etc/dhcp/dhcpd.conf | grep 'max-lease-time' | awk -F ';' > '{print $1}' | awk '{print $NF}') > > Then replace the '3600' with '$TTL'Users like comments in their config files. Your script: cat /etc/dhcp/dhcpd.conf | grep 'max-lease-time' | awk -F ';' '{print $1}' | awk '{print $NF}' 7200 7200 better is this: cat /etc/dhcp/dhcpd.conf | egrep '^\s*max-lease-time' | awk -F ';' '{print $1}' | awk '{print $NF}' 7200 So this matches: max-lease-time max-lease-time max-lease-time but not: # max-lease-time btw cheaper is sed and i am a sed fan (keep it simple): time cat /etc/dhcp/dhcpd.conf|sed -nre 's/^\s*max-lease-time\s*([0-9]+).*/\1/p' 7200 real 0m0,004s user 0m0,003s sys 0m0,004s time cat /etc/dhcp/dhcpd.conf | grep 'max-lease-time' | awk -F ';' '{print $1}' | awk '{print $NF}' 7200 7200 real 0m0,006s user 0m0,004s sys 0m0,012s> Rowland-- Gruss Harry Jede
Seemingly Similar Threads
- dhcp lease time hardware in script at dhcpd/Bind/Samba wiki page
- dhcp lease time hardware in script at dhcpd/Bind/Samba wiki page
- dhcp lease time hardware in script at dhcpd/Bind/Samba wiki page
- samba_dnsupdate options: --use-samba-tool vs. --use-nsupdate, and dhcpd dynamic updates
- dhcpd create lease error and unable to kinit for dynupdate on domain controller