summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nixos/services/router/dns-dhcp.nix71
1 files changed, 62 insertions, 9 deletions
diff --git a/nixos/services/router/dns-dhcp.nix b/nixos/services/router/dns-dhcp.nix
index 557cbda..5839227 100644
--- a/nixos/services/router/dns-dhcp.nix
+++ b/nixos/services/router/dns-dhcp.nix
@@ -1,23 +1,76 @@
{ config, lib, ... }: let
cfg = config.services._router.dnsDhcpConfig;
+ staticLeaseType = lib.types.submodule (
+ { name, ... }: {
+ options = {
+ enable = lib.mkEnableOption "enable this static lease";
+ macAddress = lib.mkOption {
+ type = lib.types.str;
+ default = "";
+ example = "00:11:22:33:44:55";
+ };
+ hostname = lib.mkOption {
+ type = lib.types.str;
+ default = name;
+ };
+ staticIp = lib.mkOption {
+ type = lib.types.str;
+ default = "";
+ example = "192.168.1.2";
+ };
+ };
+
+ config.enable = mkDefault true;
+ };
+ );
in {
options.services._router.dnsDhcpConfig = {
enable = lib.mkEnableOption "enable pre-configured unbound(outbound) + dnsmasq(local) dns(+dhcp) server";
# TODO
- defaultGateway = lib.mkOption {
- };
- localIPSubnet = lib.mkOption {
- };
dhcp = {
+ defaultGateway = lib.mkOption {
+ type = lib.types.str;
+ default = "192.168.1.1";
+ };
+ localhostIp = lib.mkOption {
+ type = lib.types.str;
+ default = "192.168.1.1";
+ description = "ip of the dns+dhcp host";
+ };
rangeStart = lib.mkOption {
+ type = lib.types.str;
+ default = "192.168.1.100";
+ description = "dhcp range start";
};
rangeEnd = lib.mkOption {
+ type = lib.types.str;
+ default = "192.168.1.250";
+ description = "dhcp range end";
};
rangeSubnetMask = lib.mkOption {
+ type = lib.types.str;
+ default = "255.255.255.0";
+ description = "dhcp range subnet";
};
leaseTime = lib.mkOption {
+ type = lib.types.str;
+ default = "12h";
+ description = "how long a dhcp lease will last. suffix is one of [h,m,s]";
};
staticLeases = lib.mkOption {
+ type = lib.types.attrsOf staticLeaseType;
+ default = {};
+ example = {
+ hostname0 = {
+ macAddress = "00:11:22:33:44:55";
+ staticIp = "192.168.1.6";
+ };
+ hostname1 = {
+ macAddress = "66:77:88:99:AA:BB";
+ staticIp = "192.168.1.7";
+ };
+ };
+ description = "dhcp static leases";
};
};
localDomain = lib.mkOption {
@@ -134,11 +187,11 @@ in {
#dhcp-host = [ mkDHCPStaticLease ... ]; # Setup static leases
#dhcp-host = dhcpStaticLeases; # Setup static leases
- dhcp-option = [
- (mkDHCPOption "router" cfg.defaultGateway) # Set default gateway for clients
- #(mkDHCPOption "ntp-server" cfg.defaultGateway) # Set ntp server for clients
- (mkDHCPOption "dns-server" cfg.defaultGateway) # Set dns server for clients
- (mkDHCPOption "domain-search" cfg.localDomain) # Add search rule to clients so they can resolve hostnames w/o the local domain suffix
+ dhcp-option = with cfg.dhcp; [
+ (mkDHCPOption "router" defaultGateway) # Set default gateway for clients
+ #(mkDHCPOption "ntp-server" defaultGateway) # Set ntp server for clients
+ (mkDHCPOption "dns-server" localhostIp) # Set dns server for clients
+ (mkDHCPOption "domain-search" localDomain) # Add search rule to clients so they can resolve hostnames w/o the local domain suffix
];
# Logging