mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-03-23 21:18:27 +01:00
Compare commits
No commits in common. "3f5ea6e161c763580a040e6daa4cc4df6489bb51" and "7fcbc3dcad2b8c139f8acd7459827480c1036a69" have entirely different histories.
3f5ea6e161
...
7fcbc3dcad
7 changed files with 13 additions and 101 deletions
|
|
@ -21,7 +21,6 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
recursive-nameserver.enable = true;
|
|
||||||
private-nameserver.enable = true;
|
private-nameserver.enable = true;
|
||||||
|
|
||||||
syncthing = {
|
syncthing = {
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
recursive-nameserver.enable = true;
|
|
||||||
private-nameserver.enable = true;
|
private-nameserver.enable = true;
|
||||||
public-nameserver = {
|
public-nameserver = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
|
||||||
|
|
@ -63,11 +63,8 @@ in
|
||||||
default =
|
default =
|
||||||
allHosts
|
allHosts
|
||||||
|> lib.attrValues
|
|> lib.attrValues
|
||||||
|> lib.filter (host: host.config.custom.services.recursive-nameserver.enable)
|
|> lib.filter (host: host.config.custom.services.private-nameserver.enable)
|
||||||
|> lib.map (
|
|> lib.map (host: host.config.custom.networking.overlay.address);
|
||||||
host:
|
|
||||||
"${host.config.custom.networking.overlay.address}:${toString host.config.custom.services.recursive-nameserver.port}"
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
implementation = lib.mkOption {
|
implementation = lib.mkOption {
|
||||||
|
|
|
||||||
|
|
@ -58,24 +58,18 @@ let
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.custom.services.private-nameserver = {
|
options.custom.services.private-nameserver.enable = lib.mkEnableOption "";
|
||||||
enable = lib.mkEnableOption "";
|
|
||||||
port = lib.mkOption {
|
|
||||||
type = lib.types.port;
|
|
||||||
default = 5335;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
services = {
|
services = {
|
||||||
nsd = {
|
nsd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
interfaces = [ "${netCfg.overlay.address}@${toString cfg.port}" ];
|
interfaces = [ netCfg.overlay.interface ];
|
||||||
zones.${netCfg.overlay.domain}.data = zoneData;
|
zones.${netCfg.overlay.domain}.data = zoneData;
|
||||||
};
|
};
|
||||||
|
|
||||||
nebula.networks.mesh.firewall.inbound = lib.singleton {
|
nebula.networks.mesh.firewall.inbound = lib.singleton {
|
||||||
inherit (cfg) port;
|
port = 53;
|
||||||
proto = "any";
|
proto = "any";
|
||||||
host = "any";
|
host = "any";
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -66,10 +66,6 @@ in
|
||||||
{
|
{
|
||||||
options.custom.services.public-nameserver = {
|
options.custom.services.public-nameserver = {
|
||||||
enable = lib.mkEnableOption "";
|
enable = lib.mkEnableOption "";
|
||||||
port = lib.mkOption {
|
|
||||||
type = lib.types.port;
|
|
||||||
default = 53;
|
|
||||||
};
|
|
||||||
zones = lib.mkOption {
|
zones = lib.mkOption {
|
||||||
type = lib.types.nonEmptyListOf lib.types.nonEmptyStr;
|
type = lib.types.nonEmptyListOf lib.types.nonEmptyStr;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
|
|
@ -77,9 +73,14 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
|
networking.firewall = {
|
||||||
|
allowedTCPPorts = [ 53 ];
|
||||||
|
allowedUDPPorts = [ 53 ];
|
||||||
|
};
|
||||||
|
|
||||||
services.nsd = {
|
services.nsd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
interfaces = [ "${netCfg.underlay.address}@${toString cfg.port}" ];
|
interfaces = [ netCfg.underlay.interface ];
|
||||||
zones =
|
zones =
|
||||||
cfg.zones
|
cfg.zones
|
||||||
|> lib.map (zone: {
|
|> lib.map (zone: {
|
||||||
|
|
@ -88,10 +89,5 @@ in
|
||||||
})
|
})
|
||||||
|> lib.listToAttrs;
|
|> lib.listToAttrs;
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.firewall = {
|
|
||||||
allowedTCPPorts = [ cfg.port ];
|
|
||||||
allowedUDPPorts = [ cfg.port ];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
allHosts,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
cfg = config.custom.services.recursive-nameserver;
|
|
||||||
netCfg = config.custom.networking;
|
|
||||||
|
|
||||||
privateNameservers =
|
|
||||||
allHosts
|
|
||||||
|> lib.attrValues
|
|
||||||
|> lib.filter (host: host.config.custom.services.private-nameserver.enable);
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options.custom.services.recursive-nameserver = {
|
|
||||||
enable = lib.mkEnableOption "";
|
|
||||||
port = lib.mkOption {
|
|
||||||
type = lib.types.port;
|
|
||||||
default = 53;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable (
|
|
||||||
lib.mkMerge [
|
|
||||||
{
|
|
||||||
services = {
|
|
||||||
unbound = {
|
|
||||||
enable = true;
|
|
||||||
settings.server = {
|
|
||||||
interface = [ "${netCfg.overlay.address}@${toString cfg.port}" ];
|
|
||||||
access-control = [ "${toString netCfg.overlay.networkCidr} allow" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
nebula.networks.mesh.firewall.inbound = lib.singleton {
|
|
||||||
inherit (cfg) port;
|
|
||||||
proto = "any";
|
|
||||||
host = "any";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.services.unbound = {
|
|
||||||
requires = [ netCfg.overlay.systemdUnit ];
|
|
||||||
after = [ netCfg.overlay.systemdUnit ];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
(lib.mkIf (privateNameservers != [ ]) {
|
|
||||||
services.unbound.settings = {
|
|
||||||
server = {
|
|
||||||
local-zone = ''"${netCfg.overlay.domain}." nodefault'';
|
|
||||||
domain-insecure = netCfg.overlay.domain;
|
|
||||||
};
|
|
||||||
|
|
||||||
stub-zone = lib.singleton {
|
|
||||||
name = netCfg.overlay.domain;
|
|
||||||
stub-addr =
|
|
||||||
privateNameservers
|
|
||||||
|> lib.map (
|
|
||||||
host:
|
|
||||||
"${host.config.custom.networking.overlay.address}@${toString host.config.custom.services.private-nameserver.port}"
|
|
||||||
);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
})
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -58,10 +58,7 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services = {
|
services.private-nameserver.enable = true;
|
||||||
recursive-nameserver.enable = true;
|
|
||||||
private-nameserver.enable = true;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -136,7 +133,7 @@
|
||||||
client1.wait_for_unit("${client1NetCfg.overlay.systemdUnit}")
|
client1.wait_for_unit("${client1NetCfg.overlay.systemdUnit}")
|
||||||
client2.wait_for_unit("${client2NetCfg.overlay.systemdUnit}")
|
client2.wait_for_unit("${client2NetCfg.overlay.systemdUnit}")
|
||||||
|
|
||||||
lighthouse.wait_for_unit("unbound.service")
|
lighthouse.wait_for_unit("nsd.service")
|
||||||
lighthouse.wait_for_open_port(53, "${lighthouseNetCfg.overlay.address}")
|
lighthouse.wait_for_open_port(53, "${lighthouseNetCfg.overlay.address}")
|
||||||
|
|
||||||
server.wait_for_unit("sshd.service")
|
server.wait_for_unit("sshd.service")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue