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 (_: hosts4: { inherit hosts4; }) pillar.hosts-inet)
|
||||||
(builtins.mapAttrs (net: dhcpData: {
|
(builtins.mapAttrs (net: dhcpData: {
|
||||||
dhcp = {
|
dhcp = {
|
||||||
inherit (dhcpData) start end time max-time;
|
inherit (dhcpData) start end time max-time fixed-hosts;
|
||||||
server =
|
server =
|
||||||
if netHasDHCP net
|
if netHasDHCP net
|
||||||
then "${net}-gw"
|
then "${net}-gw"
|
||||||
|
|
|
@ -31,6 +31,10 @@ let
|
||||||
description = "Domain name option";
|
description = "Domain name option";
|
||||||
type = types.str;
|
type = types.str;
|
||||||
};
|
};
|
||||||
|
fixed-hosts = mkOption {
|
||||||
|
type = with types; attrsOf str;
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
netOpts = { name, ... }: {
|
netOpts = { name, ... }: {
|
||||||
options = {
|
options = {
|
||||||
|
|
|
@ -16,23 +16,38 @@ in
|
||||||
interfaces = builtins.attrNames dhcpNets;
|
interfaces = builtins.attrNames dhcpNets;
|
||||||
|
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
option domain-name-servers 172.20.73.8, 9.9.9.9;
|
|
||||||
${builtins.concatStringsSep "\n" (
|
${builtins.concatStringsSep "\n" (
|
||||||
builtins.attrValues (
|
builtins.attrValues (
|
||||||
builtins.mapAttrs (net: { dhcp, subnet4Net, subnet4Len, ...}:
|
builtins.mapAttrs (net: { dhcp, subnet4Net, subnet4Len, ...}:
|
||||||
''
|
''
|
||||||
subnet ${subnet4Net} netmask ${lib.netmasks.${toString subnet4Len}} {
|
group {
|
||||||
range ${dhcp.start} ${dhcp.end};
|
|
||||||
default-lease-time ${toString dhcp.time};
|
default-lease-time ${toString dhcp.time};
|
||||||
max-lease-time ${toString dhcp.max-time};
|
max-lease-time ${toString dhcp.max-time};
|
||||||
option routers ${config.site.net.${net}.hosts4.${builtins.replaceStrings [".${net}"] [""] dhcp.router}};
|
option routers ${config.site.net.${net}.hosts4.${builtins.replaceStrings [".${net}"] [""] dhcp.router}};
|
||||||
option domain-name "${dhcp.domainName}";
|
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
|
) dhcpNets
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
'';
|
'';
|
||||||
# TODO: fixed-hosts
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue