+ AZ-PLT-1
This commit is contained in:
@@ -49,6 +49,11 @@
|
||||
|
||||
reverseProxy = {
|
||||
trustedHTTPProxies = ["${gatewayIp}/32"];
|
||||
# Required since netbird >v0.79 (netbird#7589): without this, the
|
||||
# server accepts forwarded client-IP headers from any source and
|
||||
# peers could spoof their recorded IP. Traefik reaches the server
|
||||
# container via the podman "web" bridge, sourcing from the gateway.
|
||||
trustedPeers = ["${gatewayIp}/32"];
|
||||
};
|
||||
|
||||
# Proxy Feature
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
# AZ-PLT-1 — Erstinstallation per nixos-anywhere (AZ-NIX-g2r)
|
||||
|
||||
Basis-System: disko-Layout, systemd-networkd (Public DHCP), Firewall
|
||||
default-deny, netcup Server Storage (NFSv3) nach `/var/storage`,
|
||||
vSwitch vorbereitet aber deaktiviert (Ticket offen).
|
||||
Restore-Test entfällt vorerst (AZ-NIX-7t2).
|
||||
|
||||
## Vorbedingungen (netcup CCP)
|
||||
|
||||
1. **Server Storage IPv4-Autorisierung**: CCP → Produkt PLT-1 →
|
||||
Storage Space `voln1265007a1` → *New IPv4 authorization* →
|
||||
öffentliche IPv4 von PLT-1 eintragen. **Ohne dem lehnt der Storage
|
||||
(46.38.248.210) den Mount ab.** Der Mount ist `nofail` + automount,
|
||||
ein Fehlschlag haengt den Boot nicht auf.
|
||||
2. **Rescue/SSH-Zugang**: frischer netcup VPS = Debian mit root + Passwort
|
||||
(SCP-Konsole). Fuer nixos-anywhere brauchen wir root-SSH mit Key:
|
||||
im Rescue-System (oder frischen Debian) `authorized_keys` fuer den
|
||||
Deploy-Key setzen, oder SCP-Konsole nutzen um den Key zu hinterlegen.
|
||||
3. **NIC pruefen**: Config matcht `Type = "ether"`, also jedes physische
|
||||
NIC (netcup benennt je nach Generation unterschiedlich: AZ-CLD-1 =
|
||||
`ens18`, AZ-PLT-1 = `ens3`). Im Rescue/laufenden System verifizieren
|
||||
mit `ip link`, dass genau ein ether-Interface existiert (der vSwitch
|
||||
ist ein VLAN darauf, kein zweites NIC).
|
||||
4. **Platte pruefen**: erwartet `/dev/vda` (disko). Im Rescue: `lsblk`.
|
||||
ACHTUNG: nixos-anywhere wipe die Platte komplett.
|
||||
|
||||
## Installation (vom Management-Rechner / Workstation)
|
||||
|
||||
```bash
|
||||
cd <AZ-NIX-Checkout>
|
||||
# Trockenumgebung: alle Dateisysteme werden nach /mnt gemountet, nichts wird installiert
|
||||
nix run github:nix-community/nixos-anywhere -- --dry-run --flake .#AZ-PLT-1 root@<PLT1-PUBLIC-IP>
|
||||
|
||||
# Echt (kexec auf das Installer-System, disko partitioniert, closure wird kopiert)
|
||||
nix run github:nix-community/nixos-anywhere -- --flake .#AZ-PLT-1 root@<PLT1-PUBLIC-IP>
|
||||
```
|
||||
|
||||
Der Rechner bootet danach ins konfigurierte NixOS. Login als
|
||||
`sascha.koenig` (SSH-Key, Port 2022 — root-Login ist deaktiviert).
|
||||
|
||||
## Nach der Installation
|
||||
|
||||
1. **Storage-Mount prüfen**: `ls /var/storage` (automount triggern) und
|
||||
`mount | grep voln`. Wenn leer/fehlerhaft: IPv4-Autorisierung im CCP
|
||||
pruefen, dann `systemctl restart var-storage.automount`.
|
||||
2. **NetBird beitreten** (Deployment + Monitoring via Overlay):
|
||||
`sudo netbird up` (Setup-Key/Management wie bei CLD-1/PRM-1).
|
||||
Danach in `flake.nix` bei `"AZ-PLT-1"` das `deployment.targetHost`
|
||||
auf die NetBird-IP setzen.
|
||||
3. **Colmena-Deploy testen**: `nix develop -c colmena apply AZ-PLT-1`
|
||||
(benoetigt passwordless sudo fuer `sascha.koenig` — siehe Flake-Kommentar
|
||||
bei `colmenaHive`; Entscheidung zum ersten Deploy).
|
||||
4. **vSwitch aktivieren**, sobald netcup ihn eingerichtet hat:
|
||||
`hosts/AZ-PLT-1/vswitch.nix` → `az.plt1.vswitch.enable = true;`
|
||||
und `vlanId` aus dem Ticket eintragen. IP: 10.10.0.2/24.
|
||||
5. Beobachtung: PRM-1-Monitoring (node-exporter etc.) kommt mit
|
||||
AZ-NIX-aso bzw. separat — Basis bewusst ohne Monitoring-Dienste.
|
||||
|
||||
## Troubleshooting: Netz nach Erstinstall down
|
||||
|
||||
Falls das Public-NIC nach dem Boot ohne IP bleibt (je nach netcup-Generation
|
||||
heisst es anders, z.B. `ens3` statt `ens18`; Config matcht deshalb
|
||||
`Type = "ether"`): SCP-Konsole als `sascha.koenig`, dann
|
||||
|
||||
```bash
|
||||
sudo tee /etc/systemd/network/10-public.network <<'EOF'
|
||||
[Match]
|
||||
Type=ether
|
||||
|
||||
[Network]
|
||||
DHCP=yes
|
||||
EOF
|
||||
sudo systemctl restart systemd-networkd
|
||||
```
|
||||
|
||||
Vor dem naechsten Rebuild/Colmena-Apply wieder entfernen
|
||||
(`sudo rm /etc/systemd/network/10-public.network`), sonst kollidiert die
|
||||
von NixOS generierte Datei gleichen Namens. Box leer → Neuinstall ueber
|
||||
Rescue (siehe oben) ist genauso gut.
|
||||
|
||||
## Offene Punkte (bewusst)
|
||||
|
||||
- vSwitch/VLAN-ID: Ticket noch offen (Flag aus, siehe `vswitch.nix`).
|
||||
- Firewall-Freigaben ueber Port 2022 hinaus: erst nach Traffic-Matrix
|
||||
(Outline-Gesamtplan) und mit den Folgissues (aso/01f/bt0).
|
||||
- Restore-Test: geparkt in AZ-NIX-7t2.
|
||||
@@ -0,0 +1,80 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
./hardware-configuration.nix
|
||||
./disko-config.nix
|
||||
./vswitch.nix
|
||||
];
|
||||
|
||||
boot.loader.grub = {
|
||||
efiSupport = true;
|
||||
efiInstallAsRemovable = true;
|
||||
};
|
||||
|
||||
swapDevices = [
|
||||
{
|
||||
device = "/var/lib/swapfile";
|
||||
size = 16 * 1024;
|
||||
}
|
||||
];
|
||||
|
||||
networking.hostName = "AZ-PLT-1";
|
||||
|
||||
networking.useNetworkd = true;
|
||||
services.resolved.enable = true;
|
||||
|
||||
systemd.network = {
|
||||
enable = true;
|
||||
# Type-Match statt Name: netcup benennt das NIC je Generation anders (CLD-1: ens18, PLT-1: ens3)
|
||||
networks."10-public" = {
|
||||
matchConfig.Type = "ether";
|
||||
networkConfig.DHCP = "yes";
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall = {
|
||||
enable = true;
|
||||
allowedTCPPorts = [];
|
||||
allowedUDPPorts = [];
|
||||
};
|
||||
|
||||
time.timeZone = "Europe/Berlin";
|
||||
i18n.defaultLocale = "de_DE.UTF-8";
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
neovim
|
||||
git
|
||||
ghostty
|
||||
];
|
||||
|
||||
programs.gnupg.agent = {
|
||||
enable = true;
|
||||
enableSSHSupport = true;
|
||||
};
|
||||
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
ports = [2022];
|
||||
settings = {
|
||||
PermitRootLogin = "no";
|
||||
PasswordAuthentication = false;
|
||||
};
|
||||
};
|
||||
|
||||
fileSystems."/var/storage" = {
|
||||
device = "46.38.248.210:/voln1265007a1";
|
||||
fsType = "nfs";
|
||||
options = [
|
||||
"nfsvers=3"
|
||||
"nolock"
|
||||
"nofail"
|
||||
"x-systemd.automount"
|
||||
"x-systemd.idle-timeout=60"
|
||||
];
|
||||
};
|
||||
|
||||
system.stateVersion = "26.05";
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
# AZ-PLT-1 — Basis-System per nixos-anywhere installiert (AZ-NIX-g2r).
|
||||
# Rolle: DB-/Storage-Host (Metabase + az_kpi_raw + ES 8, AZ-NIX-aso; spaeter
|
||||
# DB-Konsolidierung AZ-NIX-42r und ERPNext-Eval AZ-NIX-bt0).
|
||||
#
|
||||
# Install: siehe ./README.md (nixos-anywhere, disko-Layout, netcup CCP-Schritte).
|
||||
{
|
||||
imports = [
|
||||
../common
|
||||
./configuration.nix
|
||||
./secrets.nix
|
||||
./services
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
{
|
||||
disko.devices = {
|
||||
disk = {
|
||||
main = {
|
||||
type = "disk";
|
||||
device = "/dev/vda";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
boot = {
|
||||
size = "1M";
|
||||
type = "EF02"; # for GRUB MBR
|
||||
priority = 1;
|
||||
};
|
||||
esp = {
|
||||
size = "512M";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
mountOptions = ["defaults" "umask=0077"];
|
||||
};
|
||||
};
|
||||
root = {
|
||||
size = "80G";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "ext4";
|
||||
mountpoint = "/";
|
||||
mountOptions = ["noatime" "nodiratime" "discard"];
|
||||
};
|
||||
};
|
||||
var = {
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "ext4";
|
||||
mountpoint = "/var";
|
||||
mountOptions = ["noatime" "nodiratime" "discard"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
boot.initrd.availableKernelModules = ["ata_piix" "uhci_hcd" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod"];
|
||||
boot.initrd.kernelModules = [];
|
||||
boot.kernelModules = [];
|
||||
boot.extraModulePackages = [];
|
||||
|
||||
networking.useDHCP = false;
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
# AZ-PLT-1 Secrets (AZ-NIX-aso: Postgres-TLS + pgbouncer).
|
||||
# Gleichen Age-Dateien wie CLD-1/PRM-1 (secrets/server.crt|key.age sind
|
||||
# fuer alle Hosts inkl. PLT-1 verschluesselt — Reencrypt 01.10.).
|
||||
{config, ...}: {
|
||||
age.secrets = {
|
||||
pg-cert = {
|
||||
file = ../../secrets/server.crt.age;
|
||||
owner = "postgres";
|
||||
group = "postgres";
|
||||
mode = "0644";
|
||||
};
|
||||
pg-key = {
|
||||
file = ../../secrets/server.key.age;
|
||||
owner = "postgres";
|
||||
group = "postgres";
|
||||
mode = "0600";
|
||||
};
|
||||
pgbouncer-userlist = {
|
||||
file = ../../secrets/pgbouncer-userlist.age;
|
||||
owner = "pgbouncer";
|
||||
group = "pgbouncer";
|
||||
mode = "0640";
|
||||
};
|
||||
pgbouncer-tls-cert = {
|
||||
file = ../../secrets/server.crt.age;
|
||||
owner = "pgbouncer";
|
||||
group = "pgbouncer";
|
||||
mode = "0444";
|
||||
};
|
||||
pgbouncer-tls-key = {
|
||||
file = ../../secrets/server.key.age;
|
||||
owner = "pgbouncer";
|
||||
group = "pgbouncer";
|
||||
mode = "0400";
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
imports = [
|
||||
./netbird.nix
|
||||
./pgbouncer.nix
|
||||
./postgres.nix
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{pkgs, ...}: {
|
||||
services.netbird = {
|
||||
enable = true;
|
||||
package = pkgs.unstable.netbird;
|
||||
};
|
||||
|
||||
systemd.services.netbird = {
|
||||
environment = {
|
||||
NB_DISABLE_SSH_CONFIG = "true";
|
||||
};
|
||||
path = [
|
||||
pkgs.shadow
|
||||
pkgs.util-linux
|
||||
];
|
||||
};
|
||||
|
||||
programs.ssh.extraConfig = ''
|
||||
Match exec "${pkgs.netbird}/bin/netbird ssh detect %h %p"
|
||||
PreferredAuthentications password,publickey,keyboard-interactive
|
||||
PasswordAuthentication yes
|
||||
PubkeyAuthentication yes
|
||||
BatchMode no
|
||||
ProxyCommand ${pkgs.netbird}/bin/netbird ssh proxy %h %p
|
||||
StrictHostKeyChecking no
|
||||
UserKnownHostsFile /dev/null
|
||||
CheckHostIP no
|
||||
LogLevel ERROR
|
||||
'';
|
||||
|
||||
networking.firewall.checkReversePath = "loose";
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
# AZ-PLT-1 pgbouncer (AZ-NIX-aso), Muster wie AZ-CLD-1/services/pgbouncer.nix —
|
||||
# bewusst schlank: nur der TX-Pool fuer die zwei PLT-1-DBs (Session-Pool-DBs
|
||||
# wie outline/zammad bleiben bis AZ-NIX-42r auf CLD-1). Listen nur auf
|
||||
# Loopback, da PLT-1 (noch) keine Podman-Bridge hat — hostBridgeIP nachziehen,
|
||||
# sobald Container (ES 8, ERPNext) kommen.
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
txPort = config.m3ta.ports.get "pgbouncer-tx";
|
||||
pgPort = config.m3ta.ports.get "postgres";
|
||||
|
||||
# pgbouncer (1.24+ als auch 1.25.2) laedt bei JEDEM TLS-Setup eine CA — auch
|
||||
# bei sslmode=prefer/require ohne Verifikation. Ohne explizite Datei faellt
|
||||
# es auf die OpenSSL-Default-Verify-Paths zurueck, die hier fehlschlagen:
|
||||
# "TLS setup failed: failed to load CA: (null)" -> Startabbruch.
|
||||
# (Erkenntnis aus AZ-CLD-1, verifiziert 2026-08-20 gegen 1.24.1 + 1.25.2.)
|
||||
caBundle = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
|
||||
|
||||
mkDatabases = dbs:
|
||||
lib.listToAttrs (map (db:
|
||||
lib.nameValuePair db "host=127.0.0.1 port=${toString pgPort} dbname=${db}")
|
||||
dbs);
|
||||
in {
|
||||
services.pgbouncer = {
|
||||
enable = true;
|
||||
settings = {
|
||||
pgbouncer = {
|
||||
listen_addr = "127.0.0.1";
|
||||
listen_port = txPort;
|
||||
pool_mode = "transaction";
|
||||
|
||||
auth_type = "scram-sha-256";
|
||||
auth_file = config.age.secrets.pgbouncer-userlist.path;
|
||||
|
||||
admin_users = "sascha_koenig";
|
||||
stats_users = "sascha_koenig";
|
||||
|
||||
max_client_conn = 300;
|
||||
default_pool_size = 10;
|
||||
min_pool_size = 2;
|
||||
reserve_pool_size = 3;
|
||||
reserve_pool_timeout = 3;
|
||||
max_prepared_statements = 200;
|
||||
|
||||
client_tls_sslmode = "prefer";
|
||||
client_tls_cert_file = config.age.secrets.pgbouncer-tls-cert.path;
|
||||
client_tls_key_file = config.age.secrets.pgbouncer-tls-key.path;
|
||||
client_tls_protocols = "secure";
|
||||
client_tls_ca_file = caBundle;
|
||||
|
||||
log_connections = 1;
|
||||
log_disconnections = 1;
|
||||
server_reset_query = "DISCARD ALL";
|
||||
server_check_query = "SELECT 1";
|
||||
server_check_delay = 30;
|
||||
|
||||
server_tls_sslmode = "prefer";
|
||||
server_tls_protocols = "secure";
|
||||
server_tls_ca_file = caBundle;
|
||||
};
|
||||
databases = mkDatabases [
|
||||
"metabase"
|
||||
"az_kpi_raw"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.pgbouncer = {
|
||||
after = ["postgresql.service"];
|
||||
requires = ["postgresql.service"];
|
||||
};
|
||||
|
||||
# Kein Firewall-Eintrag noetig: pgbouncer lauscht nur auf 127.0.0.1.
|
||||
# Kestra (PRM-1) verbindet direkt auf 5432, siehe ./postgres.nix.
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
# AZ-PLT-1 Postgres (AZ-NIX-aso): Zielinstanz fuer Metabase + az_kpi_raw.
|
||||
# Muster wie AZ-CLD-1/services/postgres.nix (Postgres 17 + pgvector + SSL).
|
||||
# Rollen/DBs bewusst minimal — der Rest der CLD-1-DBs bleibt dort bis AZ-NIX-42r.
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
services.postgresql = {
|
||||
enable = true;
|
||||
enableTCPIP = true;
|
||||
package = pkgs.postgresql_17;
|
||||
settings = {
|
||||
ssl = true;
|
||||
ssl_cert_file = config.age.secrets.pg-cert.path;
|
||||
ssl_key_file = config.age.secrets.pg-key.path;
|
||||
max_connections = 60;
|
||||
shared_buffers = "4GB";
|
||||
work_mem = "8MB";
|
||||
superuser_reserved_connections = 5;
|
||||
idle_in_transaction_session_timeout = "10min";
|
||||
idle_session_timeout = "2h";
|
||||
tcp_keepalives_idle = 60;
|
||||
tcp_keepalives_interval = 10;
|
||||
tcp_keepalives_count = 6;
|
||||
deadlock_timeout = "1s";
|
||||
authentication_timeout = "30s";
|
||||
log_connections = true;
|
||||
log_disconnections = true;
|
||||
log_lock_waits = true;
|
||||
};
|
||||
extensions = with pkgs.postgresql17Packages; [
|
||||
pgvector
|
||||
];
|
||||
# Cutover (AZ-NIX-aso): Passwoerter hier sind Initialwerte; beim Umzug per
|
||||
# ALTER USER auf die Werte aus den bestehenden Secrets setzen (metabase-env,
|
||||
# kestra auf PRM-1) — dann aendert sich fuer keine App ein Credential.
|
||||
# az_kpi_raw wird per pg_dump (CLD-1) | pg_restore --clean --if-exists hierher
|
||||
# eingespielt; die GRANTs fuer kestra_prm kommen aus dem Dump mit.
|
||||
initialScript = pkgs.writeText "plt1-initScript" ''
|
||||
CREATE USER metabase WITH ENCRYPTED PASSWORD 'metabase';
|
||||
CREATE DATABASE metabase;
|
||||
ALTER DATABASE metabase OWNER to metabase;
|
||||
ALTER DATABASE metabase CONNECTION LIMIT 15;
|
||||
|
||||
CREATE USER kestra_prm WITH ENCRYPTED PASSWORD 'kestra_prm';
|
||||
CREATE DATABASE az_kpi_raw OWNER metabase;
|
||||
'';
|
||||
authentication = pkgs.lib.mkOverride 10 ''
|
||||
# Local connections (Unix socket)
|
||||
local all postgres peer
|
||||
local metabase,az_kpi_raw metabase scram-sha-256
|
||||
|
||||
# Localhost connections (Metabase laeuft auf demselben Host)
|
||||
host metabase,az_kpi_raw metabase 127.0.0.1/32 scram-sha-256
|
||||
host metabase,az_kpi_raw metabase ::1/128 scram-sha-256
|
||||
|
||||
# PRM-1-Kestra schreibt az_kpi_raw (NetBird, siehe firewall unten)
|
||||
host az_kpi_raw kestra_prm 100.91.49.26/32 scram-sha-256
|
||||
|
||||
# Deny all other connections
|
||||
local all all reject
|
||||
host all all 0.0.0.0/0 reject
|
||||
host all all ::/0 reject
|
||||
'';
|
||||
};
|
||||
|
||||
services.postgresqlBackup = {
|
||||
enable = true;
|
||||
startAt = "03:10:00";
|
||||
databases = ["az_kpi_raw" "metabase"];
|
||||
# Verschiffen Richtung NFS-/var/storage geschieht mit AZ-NIX-7t2 (Retention).
|
||||
};
|
||||
|
||||
# Erste gezielte Oeffnung der default-deny-Firewall (Traffic-Matrix):
|
||||
# Postgres nur von PRM-1 (Kestra) ueber NetBird — Muster wie AZ-CLD-1.
|
||||
networking.firewall.extraCommands = ''
|
||||
iptables -A INPUT -p tcp -s 100.91.49.26/32 --dport 5432 -j ACCEPT
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.az.plt1.vswitch;
|
||||
in {
|
||||
options.az.plt1.vswitch = {
|
||||
enable = mkEnableOption "netcup vSwitch-Interface (10.10.0.2/24, MTU 1400) auf dem Public-Link";
|
||||
|
||||
vlanId = mkOption {
|
||||
type = types.int;
|
||||
default = 0;
|
||||
description = "VLAN-ID des netcup vSwitch (aus dem netcup-Ticket/CCP).";
|
||||
};
|
||||
|
||||
address = mkOption {
|
||||
type = types.str;
|
||||
default = "10.10.0.2/24";
|
||||
description = "Statische vSwitch-Adresse von AZ-PLT-1 (Gesamtplan: 10.10.0.0/24).";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.network.netdevs."20-vswitch" = {
|
||||
netdevConfig = {
|
||||
Kind = "vlan";
|
||||
Name = "vswitch";
|
||||
};
|
||||
vlanConfig.Id = cfg.vlanId;
|
||||
};
|
||||
|
||||
systemd.network.networks."20-vswitch" = {
|
||||
matchConfig.Name = "vswitch";
|
||||
linkConfig.MTUBytes = "1400";
|
||||
address = [cfg.address];
|
||||
};
|
||||
|
||||
systemd.network.networks."10-public".vlan = ["vswitch"];
|
||||
};
|
||||
}
|
||||
@@ -66,6 +66,23 @@
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/mnt/zeugnisse" = {
|
||||
device = "//192.168.152.201/Dokumente/Zeugnisse/01-Eingehende-Zeugnisse";
|
||||
fsType = "cifs";
|
||||
options = [
|
||||
"credentials=${config.age.secrets.smb-autoablage.path}"
|
||||
"domain=az-group.local"
|
||||
"uid=0"
|
||||
"gid=0"
|
||||
"file_mode=0777"
|
||||
"dir_mode=0777"
|
||||
"iocharset=utf8"
|
||||
"nofail"
|
||||
"x-systemd.automount"
|
||||
"x-systemd.idle-timeout=60"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/mnt/SkriptHelper" = {
|
||||
device = "//192.168.152.98/SkriptHelper";
|
||||
fsType = "cifs";
|
||||
|
||||
@@ -90,6 +90,9 @@ in {
|
||||
smb-autoablage = {
|
||||
file = ../../secrets/smb-autoablage.age;
|
||||
};
|
||||
technitium-env = {
|
||||
file = ../../secrets/technitium-env.age;
|
||||
};
|
||||
}
|
||||
// lib.optionalAttrs (builtins.pathExists ntfyGrafanaWebhookSecret) {
|
||||
ntfy-grafana-webhook = {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
./online3dviewer.nix
|
||||
./semaphore.nix
|
||||
./stirling-pdf.nix
|
||||
./technitium-dns.nix
|
||||
];
|
||||
system.activationScripts.createPodmanNetworkWeb = lib.mkAfter ''
|
||||
if ! /run/current-system/sw/bin/podman network exists web; then
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
{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";
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
"/mnt/SkriptHelper"
|
||||
"/mnt/DMS-ALT-INBOX"
|
||||
"/mnt/DMS-INBOX"
|
||||
"/mnt/zeugnisse"
|
||||
];
|
||||
in {
|
||||
services.n8n = {
|
||||
|
||||
@@ -73,4 +73,8 @@
|
||||
((lib.filterAttrs (_: lib.isType "flake")) inputs);
|
||||
nixPath = ["/etc/nix/path"];
|
||||
};
|
||||
|
||||
# AZ-NIX-9aj: nicht-interaktive Aktivierung (Colmena-apply, Wartung).
|
||||
# Vertretbar: sshd key-only auf Port 2022, PasswordAuthentication off.
|
||||
security.sudo.wheelNeedsPassword = false;
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
bpi = 3033;
|
||||
excalidraw = 3034;
|
||||
online3dviewer = 3035;
|
||||
technitium-dns = 5380;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user