Extract modules from roles
This commit is contained in:
parent
120e6e66b5
commit
0a5c15105b
14 changed files with 9 additions and 22 deletions
52
modules/router-dns/default.nix
Normal file
52
modules/router-dns/default.nix
Normal file
|
@ -0,0 +1,52 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
routerCfg = config.services.router;
|
||||
dhcpCfg = config.services.router.dhcp;
|
||||
cfg = config.services.router.recursiveDns;
|
||||
in {
|
||||
options.services.router.recursiveDns = {
|
||||
enable = mkEnableOption "router recursive dns service";
|
||||
|
||||
networkIdIp = mkOption {
|
||||
type = types.str;
|
||||
example = "192.168.0.0";
|
||||
description = ''
|
||||
Network ID IP of local network.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services.unbound = let
|
||||
revIpDomain = concatStringsSep "."
|
||||
(reverseList (take 3 (splitString "." cfg.networkIdIp)));
|
||||
in {
|
||||
enable = true;
|
||||
interfaces = [ "127.0.0.1" routerCfg.internalRouterIP ];
|
||||
allowedAccess = [
|
||||
"127.0.0.0/24"
|
||||
"${cfg.networkIdIp}/${toString routerCfg.internalPrefixLength}"
|
||||
];
|
||||
extraConfig = mkIf dhcpCfg.enable ''
|
||||
# Custom configuration (leave this note to assure indentation!)
|
||||
do-not-query-localhost: no
|
||||
private-domain: "${dhcpCfg.localDomain}."
|
||||
domain-insecure: "${dhcpCfg.localDomain}."
|
||||
private-domain: "${revIpDomain}.in-addr.arpa."
|
||||
domain-insecure: "${revIpDomain}.in-addr.arpa."
|
||||
local-zone: "${revIpDomain}.in-addr.arpa" transparent
|
||||
|
||||
forward-zone:
|
||||
name: "${dhcpCfg.localDomain}."
|
||||
forward-addr: 127.0.0.1@${toString dhcpCfg.localDnsPort}
|
||||
|
||||
forward-zone:
|
||||
name: "${revIpDomain}.in-addr.arpa."
|
||||
forward-addr: 127.0.0.1@${toString dhcpCfg.localDnsPort}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue