DNS: Import local hosts into unbound

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Michael Tremer
2016-09-12 20:46:02 +01:00
parent 6f5d8f0cce
commit 36792be6ce
2 changed files with 19 additions and 79 deletions

View File

@@ -9,6 +9,9 @@
USE_FORWARDERS=1
# Cache any local zones for 60 seconds
LOCAL_TTL=60
# Load optional configuration
[ -e "/etc/sysconfig/unbound" ] && . /etc/sysconfig/unbound
@@ -64,6 +67,19 @@ update_forwarders() {
fi
}
update_hosts() {
local enabled address hostname domainname
while IFS="," read -r enabled address hostname domainname; do
[ "${enabled}" = "on" ] || continue
# Build FQDN
local fqdn="${hostname}.${domainname}"
unbound-control -q local_data "${fqdn} ${LOCAL_TTL} IN A ${address}"
done < /var/ipfire/main/hosts
}
write_interfaces_conf() {
(
config_header
@@ -182,6 +198,9 @@ case "$1" in
# Update any known forwarding name servers
update_forwarders
# Update hosts
update_hosts
;;
stop)