diff options
author | Julien Cassette <julien.cassette@gmail.com> | 2023-11-03 18:42:48 +0100 |
---|---|---|
committer | Tianling Shen <cnsztl@gmail.com> | 2023-11-13 10:52:05 +0800 |
commit | b4a31f92deb8de923d6bc6fb12506e24f4475581 (patch) | |
tree | a06bb571d09d5544f2c9bbde916efb18b3587c50 /net | |
parent | b8298a9b9114b20b1b104e36a40dc5769b26549d (diff) |
unbound: create extra host records from DHCP static leases
The "Extra DNS" option allows to create records from the DHCP
"Hostnames" configuration entries.
This allows to create such records from the DHCP "Static leases"
configuration entries too.
Fixes: #22593
Signed-off-by: Julien Cassette <julien.cassette@gmail.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/unbound/files/dnsmasq.sh | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/net/unbound/files/dnsmasq.sh b/net/unbound/files/dnsmasq.sh index eae8dae98..b507535f3 100644 --- a/net/unbound/files/dnsmasq.sh +++ b/net/unbound/files/dnsmasq.sh @@ -69,7 +69,7 @@ create_local_zone() { ############################################################################## -create_host_record() { +create_host_record_from_domain() { local cfg="$1" local ip name debug_ip @@ -102,6 +102,35 @@ create_host_record() { ############################################################################## +create_host_record_from_host() { + local cfg="$1" + local dns ip name + + # basefiles dhcp "host" clause which means host A and PTR records + config_get dns "$cfg" dns + config_get ip "$cfg" ip + config_get name "$cfg" name + + + if [ -n "$name" ] && [ -n "$ip" ] && [ $dns -eq 1 ] ; then + case $name in + *.*) + # domain present, do nothing + ;; + *) + name="$name.$UB_TXT_DOMAIN" + ;; + esac + + + create_local_zone "$name" + DM_LIST_LOCAL_DATA="$DM_LIST_LOCAL_DATA $name.@@300@@IN@@A@@$ip" + DM_LIST_LOCAL_PTR="$DM_LIST_LOCAL_PTR $ip@@300@@$name" + fi +} + +############################################################################## + create_mx_record() { local cfg="$1" local domain relay pref record @@ -215,7 +244,8 @@ dnsmasq_inactive() { # Parasite from the uci.dhcp.domain clauses DM_LIST_KNOWN_ZONES="$DM_LIST_KNOWN_ZONES $UB_TXT_DOMAIN" config_load dhcp - config_foreach create_host_record domain + config_foreach create_host_record_from_domain domain + config_foreach create_host_record_from_host host if [ $UB_D_EXTRA_DNS -gt 1 ] ; then |