unbound: Set domains with local data into type transparent mode

Message ID 20200406151025.18320-1-michael.tremer@ipfire.org
State Accepted
Commit 1b6b8d97aac8a8056a4ef5c9d571a1947551e17f
Headers
Series unbound: Set domains with local data into type transparent mode |

Commit Message

Michael Tremer April 6, 2020, 3:10 p.m. UTC
  Records which are from the same domain than the IPFire hostname
might not be returned by unbound. This change explicitely instructs
unbound to check local data before checking the global DNS.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 src/initscripts/system/unbound | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
  

Patch

diff --git a/src/initscripts/system/unbound b/src/initscripts/system/unbound
index 1cf26ec0e..35477ae28 100644
--- a/src/initscripts/system/unbound
+++ b/src/initscripts/system/unbound
@@ -72,8 +72,18 @@  write_hosts_conf() {
 			echo "local-data: \"${address} ${LOCAL_TTL} IN PTR ${HOSTNAME}\""
 		done
 
-		# Add all hosts
 		local enabled address hostname domainname generateptr
+
+		# Find all unique domain names
+		while IFS="," read -r enabled address hostname domainname generateptr; do
+			[ "${enabled}" = "on" ] || continue
+
+			echo "${domainname}"
+		done < /var/ipfire/main/hosts | sort -u | while read -r domainname; do
+			echo "local-zone: ${domainname} typetransparent"
+		done
+
+		# Add all hosts
 		while IFS="," read -r enabled address hostname domainname generateptr; do
 			[ "${enabled}" = "on" ] || continue