diff --git a/nixos/network/config.nix b/nixos/network/config.nix index 286645a..f18d3ed 100644 --- a/nixos/network/config.nix +++ b/nixos/network/config.nix @@ -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 diff --git a/nixos/network/options.nix b/nixos/network/options.nix index f69457d..9dc1c8a 100644 --- a/nixos/network/options.nix +++ b/nixos/network/options.nix @@ -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 {