system/roles/auth-dns.nix (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | {
config,
pkgs,
lib,
...
}:
let
inherit (lib.lists) flatten;
inherit (lib.strings) concatStringsSep;
he = {
notify = "216.218.130.2";
axfr = [
"216.218.133.2"
"2001:470:600::2"
];
};
iplist = ips: concatStringsSep "," (flatten ips);
domain = config.networking.domain;
in
{
age.secrets.powerdns.file = ../../secrets/powerdns.age;
networking.firewall = {
allowedTCPPorts = [ 53 ];
allowedUDPPorts = [ 53 ];
};
services.powerdns = {
enable = true;
secretFile = config.age.secrets.powerdns.path;
extraConfig = ''
launch=gsqlite3
dnsupdate=yes
allow-dnsupdate-from=0.0.0.0/0,::/0
only-notify=
also-notify=${iplist [ he.notify ]}
allow-axfr-ips=${iplist [ he.axfr ]}
expand-alias=yes
outgoing-axfr-expand-alias=yes
resolver=1.1.1.1
log-dns-details=no
log-dns-queries=no
loglevel=5
primary=yes
send-signed-notify=no
default-api-rectify=yes
default-soa-edit=inception-increment
api=yes
# replaced by secretFile/envsubst
api-key=$API_KEY
gsqlite3-database=/var/db/pdns/zones.db
gsqlite3-pragma-foreign-keys=yes
gsqlite3-dnssec=yes
'';
};
environment.systemPackages = [ pkgs.pdns ];
services.caddy.virtualHosts = {
"pdns.${domain}" = {
extraConfig = ''
log {
output discard
}
reverse_proxy 127.0.0.1:8081
'';
};
};
}
|