forked from zentralwerk/network
dhcp-server.nix: add fixed-hosts
This commit is contained in:
parent
df3ef74862
commit
775b91fb18
|
@ -32,7 +32,7 @@ in
|
|||
(builtins.mapAttrs (_: hosts4: { inherit hosts4; }) pillar.hosts-inet)
|
||||
(builtins.mapAttrs (net: dhcpData: {
|
||||
dhcp = {
|
||||
inherit (dhcpData) start end time max-time;
|
||||
inherit (dhcpData) start end time max-time fixed-hosts;
|
||||
server =
|
||||
if netHasDHCP net
|
||||
then "${net}-gw"
|
||||
|
|
|
@ -31,6 +31,10 @@ let
|
|||
description = "Domain name option";
|
||||
type = types.str;
|
||||
};
|
||||
fixed-hosts = mkOption {
|
||||
type = with types; attrsOf str;
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
netOpts = { name, ... }: {
|
||||
options = {
|
||||
|
|
|
@ -16,23 +16,38 @@ in
|
|||
interfaces = builtins.attrNames dhcpNets;
|
||||
|
||||
extraConfig = ''
|
||||
option domain-name-servers 172.20.73.8, 9.9.9.9;
|
||||
${builtins.concatStringsSep "\n" (
|
||||
builtins.attrValues (
|
||||
builtins.mapAttrs (net: { dhcp, subnet4Net, subnet4Len, ...}:
|
||||
''
|
||||
subnet ${subnet4Net} netmask ${lib.netmasks.${toString subnet4Len}} {
|
||||
range ${dhcp.start} ${dhcp.end};
|
||||
group {
|
||||
default-lease-time ${toString dhcp.time};
|
||||
max-lease-time ${toString dhcp.max-time};
|
||||
option routers ${config.site.net.${net}.hosts4.${builtins.replaceStrings [".${net}"] [""] dhcp.router}};
|
||||
option domain-name "${dhcp.domainName}";
|
||||
option domain-name-servers 172.20.73.8, 9.9.9.9;
|
||||
|
||||
subnet ${subnet4Net} netmask ${lib.netmasks.${toString subnet4Len}} {
|
||||
range ${dhcp.start} ${dhcp.end};
|
||||
}
|
||||
|
||||
${builtins.concatStringsSep "\n" (
|
||||
builtins.attrValues (
|
||||
builtins.mapAttrs (addr: hwaddr:
|
||||
''
|
||||
host ${addr} {
|
||||
hardware ethernet ${hwaddr};
|
||||
fixed-address ${addr};
|
||||
}
|
||||
''
|
||||
) dhcp.fixed-hosts
|
||||
)
|
||||
)}
|
||||
}
|
||||
''
|
||||
) dhcpNets
|
||||
)
|
||||
)}
|
||||
'';
|
||||
# TODO: fixed-hosts
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue