nameservers: Specify ports

This commit is contained in:
SebastianStork 2026-03-02 16:54:07 +01:00
parent 7fcbc3dcad
commit 2aba83de58
Signed by: SebastianStork
SSH key fingerprint: SHA256:tRrGdjYOwgHxpSc/wTOZQZEjxcb15P0tyXRsbAfd+2Q
3 changed files with 23 additions and 10 deletions

View file

@ -64,7 +64,10 @@ in
allHosts
|> lib.attrValues
|> lib.filter (host: host.config.custom.services.private-nameserver.enable)
|> lib.map (host: host.config.custom.networking.overlay.address);
|> lib.map (
host:
"${host.config.custom.networking.overlay.address}:${toString host.config.custom.services.private-nameserver.port}"
);
};
implementation = lib.mkOption {

View file

@ -58,18 +58,24 @@ let
};
in
{
options.custom.services.private-nameserver.enable = lib.mkEnableOption "";
options.custom.services.private-nameserver = {
enable = lib.mkEnableOption "";
port = lib.mkOption {
type = lib.types.port;
default = 5335;
};
};
config = lib.mkIf cfg.enable {
services = {
nsd = {
enable = true;
interfaces = [ netCfg.overlay.interface ];
interfaces = [ "${netCfg.overlay.address}@${toString cfg.port}" ];
zones.${netCfg.overlay.domain}.data = zoneData;
};
nebula.networks.mesh.firewall.inbound = lib.singleton {
port = 53;
inherit (cfg) port;
proto = "any";
host = "any";
};

View file

@ -66,6 +66,10 @@ in
{
options.custom.services.public-nameserver = {
enable = lib.mkEnableOption "";
port = lib.mkOption {
type = lib.types.port;
default = 53;
};
zones = lib.mkOption {
type = lib.types.nonEmptyListOf lib.types.nonEmptyStr;
default = [ ];
@ -73,14 +77,9 @@ in
};
config = lib.mkIf cfg.enable {
networking.firewall = {
allowedTCPPorts = [ 53 ];
allowedUDPPorts = [ 53 ];
};
services.nsd = {
enable = true;
interfaces = [ netCfg.underlay.interface ];
interfaces = [ "${netCfg.underlay.address}@${toString cfg.port}" ];
zones =
cfg.zones
|> lib.map (zone: {
@ -89,5 +88,10 @@ in
})
|> lib.listToAttrs;
};
networking.firewall = {
allowedTCPPorts = [ cfg.port ];
allowedUDPPorts = [ cfg.port ];
};
};
}