nixos-config/config/services/named.nix

113 lines
3.1 KiB
Nix
Raw Normal View History

2022-03-12 21:02:54 +00:00
{ pkgs, config, dns, hosts-list, ... }:
2022-01-15 13:44:34 +00:00
let
internalIP = import ../../utils/getInternalIP.nix config;
createListenEntry = ip: "inet ${ip} port 8653 allow { any; };";
2022-01-15 13:44:34 +00:00
listenEntries = builtins.map createListenEntry internalIP.listenIPsBare;
2022-03-20 09:06:39 +00:00
darkkirb-de = import ../../zones/darkkirb.de.nix { inherit dns; };
2022-02-08 21:01:33 +00:00
chir-rs = import ../../zones/chir.rs.nix { inherit dns; };
int-chir-rs = import ../../zones/int.chir.rs.nix { inherit dns; };
2022-03-12 21:02:54 +00:00
rpz-int-chir-rs = import ../../zones/rpz.int.chir.rs.nix { inherit pkgs hosts-list; };
2022-02-08 21:01:33 +00:00
signzone = import ../../zones/signzone.nix;
2022-01-15 13:44:34 +00:00
in
{
2022-02-08 21:01:33 +00:00
imports = [
(signzone {
inherit dns;
ksk = "services/dns/rs/chir/32969";
zsk = "services/dns/rs/chir/51207";
2022-02-08 21:01:33 +00:00
zone = chir-rs;
2022-02-09 08:47:35 +00:00
zonename = "chir.rs";
2022-02-08 21:01:33 +00:00
})
(signzone {
inherit dns;
ksk = "services/dns/rs/chir/int/35133";
zsk = "services/dns/rs/chir/int/19631";
zone = int-chir-rs;
zonename = "int.chir.rs";
})
2022-03-20 09:06:39 +00:00
(signzone {
inherit dns;
ksk = "services/dns/de/darkkirb/53136";
zsk = "services/dns/de/darkkirb/61825";
zone = darkkirb-de;
zonename = "darkkirb.de";
})
2022-02-08 21:01:33 +00:00
];
2022-01-14 19:56:02 +00:00
services.bind = {
enable = true;
zones = {
"darkkirb.de" = {
2022-03-20 09:06:39 +00:00
master = true;
file = "/var/lib/named/darkkirb.de";
};
"_acme-challenge.darkkirb.de" = {
master = true;
file = "_acme-challenge.darkkirb.de";
extraConfig = ''
update-policy {
grant certbot. name _acme-challenge.darkkirb.de. txt;
};
'';
2022-01-14 19:56:02 +00:00
};
"chir.rs" = {
2022-02-09 08:47:35 +00:00
master = true;
file = "/var/lib/named/chir.rs";
2022-01-14 19:56:02 +00:00
};
2022-02-09 08:47:35 +00:00
"_acme-challenge.chir.rs" = {
2022-02-08 21:01:33 +00:00
master = true;
2022-02-09 08:47:35 +00:00
file = "_acme-challenge.chir.rs";
extraConfig = ''
update-policy {
grant certbot. name _acme-challenge.chir.rs. txt;
2022-02-09 08:54:55 +00:00
};
2022-02-09 08:47:35 +00:00
'';
2022-02-08 21:01:33 +00:00
};
2022-01-14 19:56:02 +00:00
"int.chir.rs" = {
master = true;
file = "/var/lib/named/int.chir.rs";
};
"_acme-challenge.int.chir.rs" = {
master = true;
file = "_acme-challenge.int.chir.rs";
extraConfig = ''
update-policy {
grant certbot. name _acme-challenge.int.chir.rs. txt;
};
'';
2022-01-14 19:56:02 +00:00
};
"rpz.int.chir.rs" = {
2022-03-12 21:02:54 +00:00
master = true;
file = "${rpz-int-chir-rs}";
2022-01-14 19:56:02 +00:00
};
};
2022-01-15 13:44:34 +00:00
extraConfig = ''
statistics-channels {
${toString listenEntries}
2022-01-15 13:46:28 +00:00
};
2022-02-09 08:47:35 +00:00
include "/run/secrets/services/dns/named-keys";
2022-01-15 13:44:34 +00:00
'';
2022-01-15 14:03:51 +00:00
extraOptions = ''
allow-recursion {
127.0.0.1;
::1;
fc00::/7;
};
recursion yes;
response-policy {
zone "rpz.int.chir.rs";
};
dnssec-validation yes;
'';
2022-01-14 19:56:02 +00:00
};
networking.firewall.allowedTCPPorts = [ 53 ];
networking.firewall.allowedUDPPorts = [ 53 ];
2022-01-15 13:44:34 +00:00
services.prometheus.exporters.bind = {
enable = true;
bindGroups = [ "server" "view" "tasks" ];
bindURI = "http://${internalIP.listenIP}:8653/";
listenAddress = internalIP.listenIP;
};
2022-02-09 08:51:04 +00:00
sops.secrets."services/dns/named-keys" = { owner = "named"; };
2022-01-14 19:56:02 +00:00
}