isc-dhcp: treat 'config host' like superset of 'config domain' 14657/head
authorPhilip Prindeville <philipp@redfish-solutions.com>
Thu, 4 Feb 2021 21:55:30 +0000 (14:55 -0700)
committerPhilip Prindeville <philipp@redfish-solutions.com>
Thu, 4 Feb 2021 21:58:33 +0000 (14:58 -0700)
Not including an A record mapping will cause nsupdate to balk at
CNAME and MX records (and probably SRV as well) because the target
will be unknown at the time of parsing, until the lease gets
activated.

We need these RR's to be in place well before the servers even
come up.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
net/isc-dhcp/Makefile
net/isc-dhcp/files/dhcpd.init

index ee5b51320197a19d74bbb1442852fecb95a95303..8db25d84112ca7c5e1d88465d4181cbd0f08e6a3 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 PKG_NAME:=isc-dhcp
 UPSTREAM_NAME:=dhcp
 PKG_VERSION:=4.4.1
-PKG_RELEASE:=14
+PKG_RELEASE:=15
 
 PKG_LICENSE:=BSD-3-Clause
 PKG_LICENSE_FILES:=LICENSE
index 14b4a27481face5c45a1f4da50b562cd4d67aaeb..414c1795619dbe9d8bf7f87b26231e956375de42 100755 (executable)
@@ -82,7 +82,8 @@ update() {
        local lhs="$1" family="$2" type="$3"
        shift 3
 
-       echo -e "$PREFIX" "$lhs $family $type $@\nsend"
+       [ $dynamicdns -eq 1 ] && \
+               echo -e "$PREFIX" "$lhs $family $type $@\nsend" >> $dyn_file
 }
 
 explode() {
@@ -245,7 +246,7 @@ static_srvhosts() {
 
 static_host_add() {
        local cfg="$1"
-       local broadcast hostid macn macs mac name ip leasetime
+       local broadcast hostid macn macs mac name ip ips revip leasetime
 
        config_get macs "$cfg" "mac"
        [ -n "$macs" ] || return 0
@@ -302,6 +303,14 @@ static_host_add() {
                config_list_foreach "$cfg" "dhcp_option" append_dhcp_options
                echo "}"
        done
+
+       ips="$ip"
+       for ip in $ips; do
+               revip="$(rev_str "$ip" ".")"
+
+               update "$name.$domain." IN A "$ip"
+               update "$revip.in-addr.arpa." IN PTR "$name.$domain."
+       done
 }
 
 static_hosts() {
@@ -396,7 +405,7 @@ dhcpd_add() {
                gateway="$IP"
        fi
 
-       gen_dhcp_subnet "$cfg" >> $config_file
+       gen_dhcp_subnet "$cfg"
 }
 
 general_config() {
@@ -540,12 +549,6 @@ start_service() {
 
                general_config > $config_file
 
-               rfc1918_nets=
-
-               config_foreach dhcpd_add dhcp 1
-
-               static_hosts >> $config_file
-
                if [ $dynamicdns -eq 1 ]; then
                        cat <<EOF > $dyn_file
 ; Generated by /etc/init.d/dhcpd at $(date)
@@ -553,15 +556,23 @@ start_service() {
 ttl $TTL
 
 EOF
+               fi
+
+               rfc1918_nets=
+
+               config_foreach dhcpd_add dhcp 1 >> $config_file
 
-                       static_cnames >> $dyn_file
+               static_hosts >> $config_file
 
-                       static_domains >> $dyn_file
+               static_cnames >> $config_file
 
-                       static_mxhosts >> $dyn_file
+               static_domains >> $config_file
 
-                       static_srvhosts >> $dyn_file
+               static_mxhosts >> $config_file
 
+               static_srvhosts >> $config_file
+
+               if [ $dynamicdns -eq 1 ]; then
                        nsupdate -l -v $dyn_file
 
                        rm -f $dyn_file