Add ddns-update-on-renew option and higher lease time

Update DDNS entries on renew of lease. Automatically
fixes stale and missing DNS entries.

increase lease time to 15 minutes on priv networks
This commit is contained in:
Daniel Poelzleithner 2024-04-18 13:46:33 +02:00
parent c277a38f5c
commit 5e36c91ef6
3 changed files with 13 additions and 3 deletions

View File

@ -16,9 +16,10 @@ lib.mkMerge (
site.net."priv${toString n}" = {
dhcp = {
server = "priv${toString n}-gw";
time = 300;
time = 900;
max-time = 60 * 24 * 3600;
router = "priv${toString n}-gw";
updateOnRenewal = true;
};
domainName = "priv${toString n}.zentralwerk.org";
dynamicDomain = true;

View File

@ -96,6 +96,11 @@ let
type = with types; attrsOf str;
default = {};
};
updateOnRenewal = mkOption {
type = types.bool;
default = false;
description = "Update DNS entry on renewal";
};
};
netOpts = { name, ... }: {

View File

@ -29,6 +29,10 @@ in
# TODO: use with kea >= 2.5.0
# ddns-conflict-resolution-mode = "check-exists-with-dhcid";
ddns-use-conflict-resolution = false;
ddns-replace-client-name = "when-not-present";
# fix old, wrong or lost dns entries on renewal
ddns-update-on-renew = builtins.any (a: a)
(concatMapDhcpNets (net: { dhcp, ... }: dhcp.updateOnRenewal));
expired-leases-processing.hold-reclaimed-time = builtins.foldl' lib.max
3600 (concatMapDhcpNets (net: { dhcp, ... }: dhcp.max-time));
@ -38,8 +42,8 @@ in
pools = [ {
pool = "${dhcp.start} - ${dhcp.end}";
} ];
renew-timer = builtins.ceil (.5 * dhcp.time);
rebind-timer = builtins.ceil (.85 * dhcp.time);
renew-timer = builtins.ceil (0.5 * dhcp.time);
rebind-timer = builtins.ceil (0.85 * dhcp.time);
valid-lifetime = dhcp.time;
option-data = [ {
space = "dhcp4";