Files
AZ-NIX-SERVERS/hosts/AZ-PRM-1/services/containers/technitium-dns.nix
T
m3ta-chiron 2e9db9dfa1 feat(wartungsmodus): AZ-PRM-1 aktivieren + vollständige Registry (18 Dienste)
- extraServices.maintenance.enable + notify.url https://ping.az-gruppe.com (Q7)
- Selbstanmeldung (Q3) in allen 16 Router-Modulen, 18 Einträge:
  traefik-routing.nix bündelt prtg/home-assistant/azdesk
- Bewusst unregistriert (Policy): r.l (Traefik-Dashboard), loki-push
- error-pages-Verkabelung der Router bleibt Ticket 05 (AZ-NIX-9m4)
2026-10-03 15:27:04 +02:00

91 lines
4.0 KiB
Nix

{config, ...}: let
serviceName = "technitium-dns";
# Web console port, bound to localhost only and routed via Traefik.
servicePort = config.m3ta.ports.get serviceName;
dnsPort = 53;
containerIp = "10.89.0.18";
# eth0 addresses (see ports comment below)
hostLanIpv4Primary = "192.168.152.76";
hostLanIpv4Secondary = "192.168.153.217";
# Subnets allowed to query the DNS server:
# 192.168.152.0/23 — AZ LAN (192.168.152.0 + 192.168.153.0)
# 192.168.154.0/24 — AZ LAN segment 154
# 100.91.0.0/16 — NetBird overlay (wt0)
allowedDnsClients = "{ 192.168.152.0/23, 192.168.154.0/24, 100.91.0.0/16 }";
in {
virtualisation.oci-containers.containers."${serviceName}" = {
image = "docker.io/technitium/dns-server:latest";
environment = {
# Only plain DNS (53) + web console are exposed; optional encrypted
# protocols stay disabled until their ports are published too.
DNS_SERVER_OPTIONAL_PROTOCOL_DNS_OVER_HTTP = "false";
DNS_SERVER_OPTIONAL_PROTOCOL_DNS_OVER_TLS = "false";
DNS_SERVER_OPTIONAL_PROTOCOL_DNS_OVER_QUIC = "false";
DNS_SERVER_LOG_USING_LOCAL_TIME = "true";
};
# Provides DNS_SERVER_ADMIN_PASSWORD (applied on first run only).
environmentFiles = [config.age.secrets.technitium-env.path];
# DNS is published on the explicit eth0 addresses instead of a wildcard
# (-p 53:53): podman pre-binds every published host port in the host netns
# (libpod/oci_util.go bindPorts), and a wildcard bind for port 53 fails
# with "address already in use" because these sockets already hold :53 on
# specific addresses without SO_REUSEADDR:
# - aardvark-dns on the podman bridge gateways (10.89.0.1/10.89.9.1/10.89.10.1)
# - netbird.service on the NetBird overlay IP (wt0, 100.91.49.26)
# NetBird peers therefore query Technitium via the LAN addresses, not via
# 100.91.49.26 (that port is served by the netbird embedded DNS server,
# which answers az-group.local for the overlay). IPs come from DHCP
# (NetworkManager, eth0 "Kabelgebundene Verbindung", method=auto) — if an
# address changes, container start fails loudly and this list must be
# updated.
ports = [
"${hostLanIpv4Primary}:${toString dnsPort}:${toString dnsPort}/udp"
"${hostLanIpv4Primary}:${toString dnsPort}:${toString dnsPort}/tcp"
"${hostLanIpv4Secondary}:${toString dnsPort}:${toString dnsPort}/udp"
"${hostLanIpv4Secondary}:${toString dnsPort}:${toString dnsPort}/tcp"
"127.0.0.1:${toString servicePort}:5380"
];
volumes = [
"technitium_dns_config:/etc/dns"
];
extraOptions = ["--network=web" "--ip=${containerIp}"];
};
networking.firewall = {
allowedUDPPorts = [dnsPort];
allowedTCPPorts = [dnsPort];
# extraInputRules run before the port accepts above: queries from
# outside the allowed subnets are rejected on the host input path.
extraInputRules = ''
iifname != "lo" ip saddr != ${allowedDnsClients} udp dport ${toString dnsPort} reject
iifname != "lo" ip saddr != ${allowedDnsClients} tcp dport ${toString dnsPort} reject
'';
# Podman (netavark) publishes port 53 via DNAT — such packets traverse
# the forward chain instead of input, so restrict that path as well.
extraForwardRules = ''
ip saddr != ${allowedDnsClients} ip daddr ${containerIp} udp dport ${toString dnsPort} reject
ip saddr != ${allowedDnsClients} ip daddr ${containerIp} tcp dport ${toString dnsPort} reject
'';
};
# Traefik configuration specific to the Technitium web console
services.traefik.dynamicConfigOptions.http = {
services.${serviceName}.loadBalancer.servers = [{url = "http://localhost:${toString servicePort}/";}];
routers.${serviceName} = {
rule = "Host(`dns.l.az-gruppe.com`)";
tls = {certResolver = "ionos";};
service = serviceName;
entrypoints = "websecure";
};
};
# Wartungsmodus: Selbstanmeldung des Dienstes (Q3).
m3ta.maintenance.services.dns = {
domains = ["dns.l.az-gruppe.com"];
desc = "Technitium (DNS-Server)";
};
}