]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
knot-resolver: Configure DHCP lease forward lookups
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 16 May 2026 13:24:03 +0000 (14:24 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 21 May 2026 15:28:01 +0000 (15:28 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/knot-resolver/kresd.conf

index 0515796f6cfcdc72668090f03580968d6816f408..31886219a0f58acc1656529af9e0b466ea1cefdd 100644 (file)
@@ -433,9 +433,40 @@ local function load_rpzs()
        RPZ_CACHE = rpz_cache
 end
 
+local function load_leases()
+       -- Load DHCP settings
+       local settings = load_settings("/var/ipfire/dhcp/settings")
+
+       -- Skip this if DNS UPDATE is being used instead
+       if settings["DNS_UPDATE_ENABLED"] == "on" then
+               return
+       end
+
+       -- Enabled on GREEN?
+       if settings["ENABLE_GREEN"] == "on" then
+               policy.add(
+                       policy.suffix(leases.answer(), {
+                               todname(settings["DOMAIN_NAME_GREEN"])
+                       })
+               )
+       end
+
+       -- Enabled on BLUE?
+       if settings["ENABLE_BLUE"] == "on" then
+               policy.add(
+                       policy.suffix(leases.answer(), {
+                               todname(settings["DOMAIN_NAME_BLUE"])
+                       })
+               )
+       end
+
+       -- TODO Reverse lookup
+end
+
 -- Reload policy if the DNS settings change
 call_on_change(
        {
+               "/var/ipfire/dhcp/settings",
                "/var/ipfire/dns/servers",
                "/var/ipfire/dns/settings",
                "/var/ipfire/dnsforward/config"
@@ -462,6 +493,9 @@ call_on_change(
                -- Load Forwarding Rules
                load_forwarding()
 
+               -- Load DHCP Leases Lookup
+               load_leases()
+
                -- Load Forwarders
                load_forwarders(settings)
        end