feat: can now handle two (or more) nameservers
This commit is contained in:
parent
8db9529449
commit
654d45a842
4 changed files with 150 additions and 28 deletions
|
@ -12,26 +12,13 @@
|
|||
|
||||
{ pkgs, lib, nodes, ... }:
|
||||
let
|
||||
# ip_pub = "193.1.99.120";
|
||||
ip_pub = "192.168.1.157";
|
||||
ip_pub = "193.1.99.120";
|
||||
ip_priv = "172.20.20.3";
|
||||
# hostname = "vendetta.skynet.ie";
|
||||
hostname = "192.168.1.157";
|
||||
hostname = ip_pub;
|
||||
|
||||
# this server will have to have dns records
|
||||
own = {
|
||||
external = [
|
||||
"vendetta A ${ip_pub}"
|
||||
"ns1 A ${ip_pub}"
|
||||
|
||||
# needs this, temporally
|
||||
"ns2 A ${ip_pub}"
|
||||
"mail A ${ip_pub}"
|
||||
];
|
||||
cname = [
|
||||
#"misc CNAME vendetta"
|
||||
];
|
||||
};
|
||||
# sets which nameserver it is
|
||||
ns = "ns1";
|
||||
in {
|
||||
imports = [
|
||||
# applications for this particular server
|
||||
|
@ -54,14 +41,29 @@ in {
|
|||
skynet_dns = {
|
||||
enable = true;
|
||||
|
||||
# this server will have to have dns records
|
||||
own = {
|
||||
nameserver = ns;
|
||||
external = [
|
||||
"vendetta A ${ip_pub}"
|
||||
"${ns} A ${ip_pub}"
|
||||
|
||||
# needs this, temporally
|
||||
"mail A ${ip_pub}"
|
||||
];
|
||||
cname = [
|
||||
#"misc CNAME vendetta"
|
||||
];
|
||||
};
|
||||
|
||||
records = {
|
||||
# using the same logic as the firewall, comments there
|
||||
external = builtins.concatLists (
|
||||
lib.attrsets.mapAttrsToList (key: value:
|
||||
if builtins.hasAttr "skynet_dns" value.config
|
||||
then (
|
||||
if value.config.deployment.targetHost == hostname
|
||||
then own.external
|
||||
if value.config.skynet_dns.enable
|
||||
then value.config.skynet_dns.own.external
|
||||
else value.config.skynet_dns.records.external
|
||||
)
|
||||
else []
|
||||
|
@ -72,8 +74,8 @@ in {
|
|||
lib.attrsets.mapAttrsToList (key: value:
|
||||
if builtins.hasAttr "skynet_dns" value.config
|
||||
then (
|
||||
if value.config.deployment.targetHost == hostname
|
||||
then own.cname
|
||||
if value.config.skynet_dns.enable
|
||||
then value.config.skynet_dns.own.cname
|
||||
else value.config.skynet_dns.records.cname
|
||||
)
|
||||
else []
|
||||
|
|
85
machines/vigil.nix
Normal file
85
machines/vigil.nix
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
|
||||
Name: https://masseffect.fandom.com/wiki/Vigil
|
||||
Why: Counterpart to Vendetta
|
||||
Type: VM
|
||||
Hardware: -
|
||||
From: 2023
|
||||
Role: DNS Server
|
||||
Notes:
|
||||
|
||||
*/
|
||||
|
||||
{ pkgs, lib, nodes, ... }:
|
||||
let
|
||||
# ip_pub = "193.1.99.121";
|
||||
ip_pub = "192.168.1.157";
|
||||
ip_priv = "172.20.20.4";
|
||||
# hostname = "vigil.skynet.ie";
|
||||
hostname = ip_pub;
|
||||
|
||||
# sets which nameserver it is
|
||||
ns = "ns2";
|
||||
in {
|
||||
imports = [
|
||||
# applications for this particular server
|
||||
../applications/dns.nix
|
||||
];
|
||||
|
||||
deployment = {
|
||||
targetHost = hostname;
|
||||
targetPort = 22;
|
||||
targetUser = "root";
|
||||
};
|
||||
|
||||
networking = {
|
||||
firewall = {
|
||||
allowedTCPPorts = [22 53];
|
||||
allowedUDPPorts = [53];
|
||||
};
|
||||
};
|
||||
|
||||
skynet_dns = {
|
||||
enable = true;
|
||||
|
||||
# this server will have to have dns records
|
||||
own = {
|
||||
nameserver = ns;
|
||||
external = [
|
||||
"vigil A ${ip_pub}"
|
||||
"${ns} A ${ip_pub}"
|
||||
];
|
||||
cname = [
|
||||
#"misc CNAME vendetta"
|
||||
];
|
||||
};
|
||||
|
||||
records = {
|
||||
# using the same logic as the firewall, comments there
|
||||
external = builtins.concatLists (
|
||||
lib.attrsets.mapAttrsToList (key: value:
|
||||
if builtins.hasAttr "skynet_dns" value.config
|
||||
then (
|
||||
if value.config.skynet_dns.enable
|
||||
then value.config.skynet_dns.own.external
|
||||
else value.config.skynet_dns.records.external
|
||||
)
|
||||
else []
|
||||
) nodes
|
||||
);
|
||||
|
||||
cname = builtins.concatLists (
|
||||
lib.attrsets.mapAttrsToList (key: value:
|
||||
if builtins.hasAttr "skynet_dns" value.config
|
||||
then (
|
||||
if value.config.skynet_dns.enable
|
||||
then value.config.skynet_dns.own.cname
|
||||
else value.config.skynet_dns.records.cname
|
||||
)
|
||||
else []
|
||||
) nodes
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue