unbound-dhcp-leases-bridge: Fall back to the default domain

Message ID 20221004133247.3915028-1-michael.tremer@ipfire.org
State Accepted
Commit ca4de263184e2d62239cc6d63caf2a0812d492b5
Headers
Series unbound-dhcp-leases-bridge: Fall back to the default domain |

Commit Message

Michael Tremer Oct. 4, 2022, 1:32 p.m. UTC
  When the bridge cannot detect a domain name for any of the leases, it
uses localdomain which is not always the best choice. So instead, this
patches changes the behaviour that we read the default domain of the
firewall.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 config/unbound/unbound-dhcp-leases-bridge | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
  

Comments

Bernhard Bitsch Oct. 4, 2022, 1:44 p.m. UTC | #1
Reviewed-by: Bernhard Bitsch <bbitsch@ipfire.org>

Am 04.10.2022 um 15:32 schrieb Michael Tremer:
> When the bridge cannot detect a domain name for any of the leases, it
> uses localdomain which is not always the best choice. So instead, this
> patches changes the behaviour that we read the default domain of the
> firewall.
> 
> Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
> ---
>   config/unbound/unbound-dhcp-leases-bridge | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/config/unbound/unbound-dhcp-leases-bridge b/config/unbound/unbound-dhcp-leases-bridge
> index 1446c88df..e89e0446b 100644
> --- a/config/unbound/unbound-dhcp-leases-bridge
> +++ b/config/unbound/unbound-dhcp-leases-bridge
> @@ -441,8 +441,11 @@ class Lease(object):
>   			if address in subnet:
>   				return subnets[subnet]
>   
> -		# Fall back to localdomain if no match could be found
> -		return "localdomain"
> +		# Load main settings
> +		settings = self.read_settings("/var/ipfire/main/settings")
> +
> +		# Fall back to the host domain if no match could be found
> +		return settings.get("DOMAINNAME", "localdomain")
>   
>   	@staticmethod
>   	@functools.cache
  

Patch

diff --git a/config/unbound/unbound-dhcp-leases-bridge b/config/unbound/unbound-dhcp-leases-bridge
index 1446c88df..e89e0446b 100644
--- a/config/unbound/unbound-dhcp-leases-bridge
+++ b/config/unbound/unbound-dhcp-leases-bridge
@@ -441,8 +441,11 @@  class Lease(object):
 			if address in subnet:
 				return subnets[subnet]
 
-		# Fall back to localdomain if no match could be found
-		return "localdomain"
+		# Load main settings
+		settings = self.read_settings("/var/ipfire/main/settings")
+
+		# Fall back to the host domain if no match could be found
+		return settings.get("DOMAINNAME", "localdomain")
 
 	@staticmethod
 	@functools.cache