dns: auto-generate zone entries from host configurations
Replace static zone file with dynamically generated records: - Add homelab.dns module with enable/cnames options - Extract IPs from systemd.network configs (filters VPN interfaces) - Use git commit timestamp as zone serial number - Move external hosts to separate external-hosts.nix Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
52
services/ns/external-hosts.nix
Normal file
52
services/ns/external-hosts.nix
Normal file
@@ -0,0 +1,52 @@
|
||||
# DNS records for hosts not managed by this flake
|
||||
# These are manually maintained and combined with auto-generated records
|
||||
{
|
||||
aRecords = {
|
||||
# 8_k8s
|
||||
"kube-blue1" = "10.69.8.150";
|
||||
"kube-blue2" = "10.69.8.151";
|
||||
"kube-blue3" = "10.69.8.152";
|
||||
"kube-blue4" = "10.69.8.153";
|
||||
"kube-blue5" = "10.69.8.154";
|
||||
"kube-blue6" = "10.69.8.155";
|
||||
"kube-blue7" = "10.69.8.156";
|
||||
"kube-blue8" = "10.69.8.157";
|
||||
"kube-blue9" = "10.69.8.158";
|
||||
"kube-blue10" = "10.69.8.159";
|
||||
|
||||
# 10
|
||||
"gw" = "10.69.10.1";
|
||||
|
||||
# 12_CORE
|
||||
"virt-mini1" = "10.69.12.11";
|
||||
"nas" = "10.69.12.50";
|
||||
"nzbget-jail" = "10.69.12.51";
|
||||
"restic" = "10.69.12.52";
|
||||
"radarr-jail" = "10.69.12.53";
|
||||
"sonarr-jail" = "10.69.12.54";
|
||||
"bazarr" = "10.69.12.55";
|
||||
"mpnzb" = "10.69.12.57";
|
||||
"pve1" = "10.69.12.75";
|
||||
"inc1" = "10.69.12.80";
|
||||
"inc2" = "10.69.12.81";
|
||||
|
||||
# 22_WLAN
|
||||
"unifi-ctrl" = "10.69.22.5";
|
||||
|
||||
# 30
|
||||
"gunter" = "10.69.30.105";
|
||||
|
||||
# 31
|
||||
"media" = "10.69.31.50";
|
||||
|
||||
# 99_MGMT
|
||||
"sw1" = "10.69.99.2";
|
||||
"testing" = "10.69.33.33";
|
||||
};
|
||||
|
||||
cnames = {
|
||||
# k8s services
|
||||
"rook" = "kube-blue4";
|
||||
"git" = "kube-blue5";
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,16 @@
|
||||
{ ... }:
|
||||
{ self, lib, ... }:
|
||||
let
|
||||
dnsLib = import ../../lib/dns-zone.nix { inherit lib; };
|
||||
externalHosts = import ./external-hosts.nix;
|
||||
|
||||
# Generate zone from flake hosts + external hosts
|
||||
# Use lastModified from git commit as serial number
|
||||
zoneData = dnsLib.generateZone {
|
||||
inherit self externalHosts;
|
||||
serial = self.sourceInfo.lastModified;
|
||||
domain = "home.2rjus.net";
|
||||
};
|
||||
in
|
||||
{
|
||||
sops.secrets.ns_xfer_key = {
|
||||
path = "/etc/nsd/xfer.key";
|
||||
@@ -26,7 +38,7 @@
|
||||
"home.2rjus.net" = {
|
||||
provideXFR = [ "10.69.13.6 xferkey" ];
|
||||
notify = [ "10.69.13.6@8053 xferkey" ];
|
||||
data = builtins.readFile ./zones-home-2rjus-net.conf;
|
||||
data = zoneData;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
{ ... }:
|
||||
{ self, lib, ... }:
|
||||
let
|
||||
dnsLib = import ../../lib/dns-zone.nix { inherit lib; };
|
||||
externalHosts = import ./external-hosts.nix;
|
||||
|
||||
# Generate zone from flake hosts + external hosts
|
||||
# Used as initial zone data before first AXFR completes
|
||||
zoneData = dnsLib.generateZone {
|
||||
inherit self externalHosts;
|
||||
serial = self.sourceInfo.lastModified;
|
||||
domain = "home.2rjus.net";
|
||||
};
|
||||
in
|
||||
{
|
||||
sops.secrets.ns_xfer_key = {
|
||||
path = "/etc/nsd/xfer.key";
|
||||
@@ -24,7 +36,7 @@
|
||||
"home.2rjus.net" = {
|
||||
allowNotify = [ "10.69.13.5 xferkey" ];
|
||||
requestXFR = [ "AXFR 10.69.13.5@8053 xferkey" ];
|
||||
data = builtins.readFile ./zones-home-2rjus-net.conf;
|
||||
data = zoneData;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
$ORIGIN home.2rjus.net.
|
||||
$TTL 1800
|
||||
@ IN SOA ns1.home.2rjus.net. admin.test.2rjus.net. (
|
||||
2066 ; serial number
|
||||
3600 ; refresh
|
||||
900 ; retry
|
||||
1209600 ; expire
|
||||
120 ; ttl
|
||||
)
|
||||
|
||||
IN NS ns1.home.2rjus.net.
|
||||
IN NS ns2.home.2rjus.net.
|
||||
IN NS ns3.home.2rjus.net.
|
||||
|
||||
; 8_k8s
|
||||
kube-blue1 IN A 10.69.8.150
|
||||
kube-blue2 IN A 10.69.8.151
|
||||
kube-blue3 IN A 10.69.8.152
|
||||
|
||||
kube-blue4 IN A 10.69.8.153
|
||||
rook IN CNAME kube-blue4
|
||||
|
||||
kube-blue5 IN A 10.69.8.154
|
||||
git IN CNAME kube-blue5
|
||||
|
||||
kube-blue6 IN A 10.69.8.155
|
||||
kube-blue7 IN A 10.69.8.156
|
||||
kube-blue8 IN A 10.69.8.157
|
||||
kube-blue9 IN A 10.69.8.158
|
||||
kube-blue10 IN A 10.69.8.159
|
||||
|
||||
; 10
|
||||
gw IN A 10.69.10.1
|
||||
|
||||
; 12_CORE
|
||||
virt-mini1 IN A 10.69.12.11
|
||||
nas IN A 10.69.12.50
|
||||
nzbget-jail IN A 10.69.12.51
|
||||
restic IN A 10.69.12.52
|
||||
radarr-jail IN A 10.69.12.53
|
||||
sonarr-jail IN A 10.69.12.54
|
||||
bazarr IN A 10.69.12.55
|
||||
mpnzb IN A 10.69.12.57
|
||||
pve1 IN A 10.69.12.75
|
||||
inc1 IN A 10.69.12.80
|
||||
inc2 IN A 10.69.12.81
|
||||
media1 IN A 10.69.12.82
|
||||
|
||||
; 13_SVC
|
||||
ns1 IN A 10.69.13.5
|
||||
ns2 IN A 10.69.13.6
|
||||
ns3 IN A 10.69.13.7
|
||||
ns4 IN A 10.69.13.8
|
||||
ha1 IN A 10.69.13.9
|
||||
nixos-test1 IN A 10.69.13.10
|
||||
http-proxy IN A 10.69.13.11
|
||||
ca IN A 10.69.13.12
|
||||
monitoring01 IN A 10.69.13.13
|
||||
jelly01 IN A 10.69.13.14
|
||||
nix-cache01 IN A 10.69.13.15
|
||||
nix-cache IN CNAME nix-cache01
|
||||
actions1 IN CNAME nix-cache01
|
||||
pgdb1 IN A 10.69.13.16
|
||||
nats1 IN A 10.69.13.17
|
||||
auth01 IN A 10.69.13.18
|
||||
vault01 IN A 10.69.13.19
|
||||
vault IN CNAME vault01
|
||||
vaulttest01 IN A 10.69.13.150
|
||||
|
||||
; http-proxy cnames
|
||||
nzbget IN CNAME http-proxy
|
||||
radarr IN CNAME http-proxy
|
||||
sonarr IN CNAME http-proxy
|
||||
ha IN CNAME http-proxy
|
||||
z2m IN CNAME http-proxy
|
||||
grafana IN CNAME http-proxy
|
||||
prometheus IN CNAME http-proxy
|
||||
alertmanager IN CNAME http-proxy
|
||||
jelly IN CNAME http-proxy
|
||||
auth IN CNAME http-proxy
|
||||
lldap IN CNAME http-proxy
|
||||
pyroscope IN CNAME http-proxy
|
||||
pushgw IN CNAME http-proxy
|
||||
|
||||
ldap IN CNAME auth01
|
||||
|
||||
|
||||
; 22_WLAN
|
||||
unifi-ctrl IN A 10.69.22.5
|
||||
|
||||
; 30
|
||||
gunter IN A 10.69.30.105
|
||||
|
||||
; 31
|
||||
media IN A 10.69.31.50
|
||||
|
||||
; 99_MGMT
|
||||
sw1 IN A 10.69.99.2
|
||||
testing IN A 10.69.33.33
|
||||
Reference in New Issue
Block a user