auto generate dhcp start and end address
This commit is contained in:
parent
392375b046
commit
e4975a4cec
2 changed files with 11 additions and 1 deletions
|
|
@ -36,6 +36,14 @@ let
|
|||
lanInterfaceIPAddress = calc.cidr.host 1 lanCfg.ipv4.range;
|
||||
netmask = calc.cidr.netmask lanCfg.ipv4.range;
|
||||
networkPrefix = builtins.elemAt (lib.splitString "/" lanCfg.ipv4.range) 1;
|
||||
dhcpStartAddress =
|
||||
if (lanCfg.ipv4.dhcp.startAddress != null)
|
||||
then lanCfg.ipv4.dhcp.startAddress
|
||||
else (calc.cidr.host 2 lanCfg.ipv4.range);
|
||||
dhcpEndAddress =
|
||||
if (lanCfg.ipv4.dhcp.endAddress != null)
|
||||
then lanCfg.ipv4.dhcp.endAddress
|
||||
else (calc.cidr.host ((calc.cidr.capacity lanCfg.ipv4.range) - 2) lanCfg.ipv4.range);
|
||||
|
||||
createLanInterface = pkgs.writeShellScript "create-lan-${lanCfg.name}-vmix" ''
|
||||
ip link add ${lanInterfaceName} type bridge
|
||||
|
|
@ -47,7 +55,7 @@ let
|
|||
lanDomainName = "${lanCfg.name}.vmix";
|
||||
lanDnsmasqConf = pkgs.writeText "dnsmasq-${lanCfg.name}.conf" (''
|
||||
listen-address=${lanInterfaceIPAddress}
|
||||
dhcp-range=${lanCfg.ipv4.dhcp.startAddress},${lanCfg.ipv4.dhcp.endAddress},${netmask},12h
|
||||
dhcp-range=${dhcpStartAddress},${dhcpEndAddress},${netmask},12h
|
||||
interface=${lanInterfaceName}
|
||||
bind-interfaces
|
||||
except-interface=lo
|
||||
|
|
|
|||
|
|
@ -118,11 +118,13 @@ with vmixLib.network;
|
|||
dhcp.startAddress = mkOption {
|
||||
type = types.nullOr (types.strMatching regex.ipv4);
|
||||
description = "Starting IP Address for DHCP clients.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
dhcp.endAddress = mkOption {
|
||||
type = types.nullOr (types.strMatching regex.ipv4);
|
||||
description = "Ending IP Address for DHCP clients.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
dns.upstream = mkOption {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue