nixos/service: add dns (bind named server)
This commit is contained in:
@@ -5,4 +5,8 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
"ntfy.age".publicKeys = [ tuxcord-ca ] ++ builtins.attrValues users;
|
"ntfy.age".publicKeys = [ tuxcord-ca ] ++ builtins.attrValues users;
|
||||||
|
|
||||||
|
# tsig-keygen sub.domain.tld.
|
||||||
|
"dns/tuxcord.key".publicKeys = [ tuxcord-ca ] ++ [ users.error users.javalsai ];
|
||||||
|
# "dns/users/XXX.key".publicKeys = [ users.XXX ];
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-1
@@ -28,6 +28,14 @@ in
|
|||||||
./vm.nix
|
./vm.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
age.secrets = {
|
||||||
|
dns-root-key = {
|
||||||
|
file = ../agenix/dns/tuxcord.key;
|
||||||
|
group = "named";
|
||||||
|
owner = "named";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
nix = {
|
nix = {
|
||||||
package = inputs'.nix-super.packages.default;
|
package = inputs'.nix-super.packages.default;
|
||||||
|
|
||||||
@@ -97,7 +105,10 @@ in
|
|||||||
|
|
||||||
extraHosts =
|
extraHosts =
|
||||||
let
|
let
|
||||||
subdomains = [ "" ".git" ];
|
subdomains = [
|
||||||
|
""
|
||||||
|
".git"
|
||||||
|
];
|
||||||
in
|
in
|
||||||
builtins.foldl' (
|
builtins.foldl' (
|
||||||
hosts-acc: domain-prefix:
|
hosts-acc: domain-prefix:
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
./dns.nix
|
||||||
./fail2ban.nix
|
./fail2ban.nix
|
||||||
./gitea.nix
|
./gitea.nix
|
||||||
./host.nix
|
./host.nix
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
{ config, ... }:
|
||||||
|
let
|
||||||
|
fqdn = "tuxcord.net";
|
||||||
|
# fqdn = config.networking.fqdn;
|
||||||
|
|
||||||
|
zonesub = _: "zonesub";
|
||||||
|
subdomain = name: "subdomain ${name}";
|
||||||
|
|
||||||
|
# careful, assumes the fqdn (name) matches the key name content
|
||||||
|
keys = [
|
||||||
|
{
|
||||||
|
name = "tuxcord.net";
|
||||||
|
path = config.age.secrets.dns-root-key.path;
|
||||||
|
type = zonesub;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
in
|
||||||
|
{
|
||||||
|
services.bind = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
extraConfig = builtins.concatStringsSep "\n" (map (key: "include \"${key.path}\";") keys);
|
||||||
|
|
||||||
|
zones = {
|
||||||
|
"${fqdn}" = {
|
||||||
|
# grant "tuxcord.net" zonesub ANY;
|
||||||
|
extraConfig = ''
|
||||||
|
update-policy {
|
||||||
|
${builtins.concatStringsSep "\n" (
|
||||||
|
map (key: "grant \"${key.name}\" ${key.type key.name} ANY;") keys
|
||||||
|
)}
|
||||||
|
};
|
||||||
|
'';
|
||||||
|
file = "/var/dns/${fqdn}.zone"; # need to put default stuff
|
||||||
|
master = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
networking.firewall.allowedTCPPorts = [ config.services.bind.listenOnPort ];
|
||||||
|
networking.firewall.allowedUDPPorts = [ config.services.bind.listenOnPort ];
|
||||||
|
|
||||||
|
environment.persistence."/persist" = {
|
||||||
|
directories = [
|
||||||
|
{
|
||||||
|
directory = "/var/dns";
|
||||||
|
group = "named";
|
||||||
|
user = "named";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user