mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 14:01:34 +01:00
Create networking abstraction on top of nebula
This commit is contained in:
parent
6804112df6
commit
252abe9443
15 changed files with 223 additions and 165 deletions
73
modules/system/services/dns.nix
Normal file
73
modules/system/services/dns.nix
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
config,
|
||||
self,
|
||||
lib,
|
||||
lib',
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.custom.services.dns;
|
||||
netCfg = config.custom.networking;
|
||||
in
|
||||
{
|
||||
options.custom.services.dns.enable = lib.mkEnableOption "";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
# meta.ports = {
|
||||
# tcp = [ 53 ];
|
||||
# udp = [ 53 ];
|
||||
# };
|
||||
|
||||
services = {
|
||||
unbound = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
server = {
|
||||
interface = [ netCfg.overlay.interface ];
|
||||
access-control = [
|
||||
"${netCfg.overlay.networkAddress}/${toString netCfg.overlay.prefixLength} allow"
|
||||
];
|
||||
|
||||
local-zone = "\"${netCfg.overlay.domain}.\" static";
|
||||
local-data =
|
||||
let
|
||||
nodeRecords =
|
||||
netCfg.nodes
|
||||
|> lib.map (node: "\"${node.hostname}.${node.overlay.domain}. A ${node.overlay.address}\"");
|
||||
serviceRecords =
|
||||
self.nixosConfigurations
|
||||
|> lib.attrValues
|
||||
|> lib.concatMap (
|
||||
host:
|
||||
host.config.meta.domains.local
|
||||
|> lib.filter (domain: lib'.isPrivateDomain domain)
|
||||
|> lib.map (domain: "\"${domain}. A ${host.config.custom.networking.overlay.address}\"")
|
||||
);
|
||||
in
|
||||
nodeRecords ++ serviceRecords;
|
||||
};
|
||||
|
||||
forward-zone = lib.singleton {
|
||||
name = ".";
|
||||
forward-addr = [
|
||||
"1.1.1.1"
|
||||
"8.8.8.8"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nebula.networks.mesh.firewall.inbound = lib.singleton {
|
||||
port = 53;
|
||||
proto = "any";
|
||||
host = "any";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.unbound = {
|
||||
requires = [ netCfg.overlay.systemdUnit ];
|
||||
after = [ netCfg.overlay.systemdUnit ];
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue