mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-22 17:02:58 +02:00
DNS: Import local hosts into unbound
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user