Every host runs node_exporter, cAdvisor (now against Podman), Alloy and the security-metrics script, on its private address. Each service declares its own expected ports, users and privileged containers next to its definition, so the security baseline follows the config instead of a separate inventory list. On ops: Prometheus, Loki, Grafana, the blackbox prober and the Postgres exporter, with the same scrape jobs, probes, retention, dashboards and 33 alert rules. Two rules matched container-era names and now match the native ones: Forgejo's log is unit forgejo.service, Grafana's route is grafana@file. Grafana keeps its default secret_key on production, because its database was written with it; rotating it is a separate step. Prometheus, Grafana and Alloy come from nixos-unstable: their data is from newer versions than 26.05 ships. LLMNR and mDNS are off: the baseline flagged them as public listeners. Tried on the rehearsal pair: all 28 scrape targets up, logs from both hosts in Loki, Grafana WireGuard-only, no unexpected port, user or container on either host. Assisted-by: Claude:opus-5-5
56 lines
1.5 KiB
Nix
56 lines
1.5 KiB
Nix
# Hetzner Cloud VM as nixos-infect leaves it: the Debian image's disk
|
|
# (sda1 ext4 root, sda14 BIOS boot, sda15 unused ESP), GRUB in the MBR.
|
|
{ lib, modulesPath, ... }:
|
|
{
|
|
imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
|
|
|
|
boot.loader.grub.device = "/dev/sda";
|
|
boot.initrd.availableKernelModules = [
|
|
"ata_piix"
|
|
"uhci_hcd"
|
|
"virtio_pci"
|
|
"virtio_scsi"
|
|
"sd_mod"
|
|
];
|
|
fileSystems."/" = {
|
|
device = "/dev/sda1";
|
|
fsType = "ext4";
|
|
};
|
|
boot.tmp.cleanOnBoot = true;
|
|
services.qemuGuest.enable = true;
|
|
|
|
# Public interface: IPv4 by DHCP, IPv6 static (asxpio.ipv6, Hetzner
|
|
# offers no router advertisements). Private network: DHCP, never the
|
|
# default route. Names differ between a switch from the bootstrap
|
|
# system (eth0) and a boot of this one (enp1s0).
|
|
networking.useDHCP = false;
|
|
networking.useNetworkd = true;
|
|
systemd.network.enable = true;
|
|
systemd.network.networks = {
|
|
"10-public" = {
|
|
matchConfig.Name = "enp1s0 eth0";
|
|
networkConfig.DHCP = "ipv4";
|
|
routes = [ { Gateway = "fe80::1"; } ];
|
|
};
|
|
"20-private" = {
|
|
matchConfig.Name = "enp7s0 ens10";
|
|
networkConfig.DHCP = "ipv4";
|
|
dhcpV4Config = {
|
|
RouteMetric = 2000;
|
|
UseDNS = false;
|
|
};
|
|
linkConfig.RequiredForOnline = "no";
|
|
};
|
|
};
|
|
# Name resolution on the local link is of no use on a server
|
|
services.resolved.settings.Resolve = {
|
|
LLMNR = false;
|
|
MulticastDNS = false;
|
|
};
|
|
|
|
networking.nameservers = lib.mkDefault [
|
|
"185.12.64.1"
|
|
"185.12.64.2"
|
|
"2a01:4ff:ff00::add:1"
|
|
];
|
|
}
|