Files
cc-ci/nix/hosts/cc-ci-hetzner/networking.nix
T
autonomic-bot c541cb1474
continuous-integration/drone/push Build is failing
networking: pin defaultGateway to eth0 (fixes no-default-route on 25.05+)
Since NixOS 25.05, scripted networking installs the default route from the
gateway interface's network-addresses-<iface>.service, matching the interface
via defaultGateway.interface or by subnet inclusion. Hetzner's off-subnet
point-to-point gateway (91.98.47.73/32 on eth0, gw 172.31.1.1) matched
neither with the bare-string form, so the 26.05 switch on 2026-08-03 left the
host with no default route and off the network (recovered via Hetzner rescue:
grubenv default back to the 24.11 generation).

With an explicit interface, the module installs both the gateway host route
and the default route from eth0's own unit:
  ip -4 route replace 172.31.1.1 proto static dev eth0
  ip -4 route replace default proto static dev eth0 via 172.31.1.1

Verified by nix eval of systemd.services.network-addresses-eth0.script.
2026-08-03 20:13:24 +00:00

47 lines
2.0 KiB
Nix

# Hetzner static networking — generated by nixos-infect at provision time.
#
# This file is server-specific: the IP, gateway, and MAC address are tied to a
# particular Hetzner instance. When provisioning a new server:
# 1. After `terraform apply` + nixos-infect completes, run:
# ssh root@<new-ip> 'cat /etc/nixos/networking.nix'
# 2. Replace this file's contents with the output and commit.
# 3. Then: `nixos-rebuild switch --flake .#cc-ci-hetzner --target-host root@<new-ip>`
#
# Current instance: 91.98.47.73 (fsn1, Hetzner server 134485294, provisioned 2026-05-31).
{ lib, ... }: {
networking = {
nameservers = [
"185.12.64.1"
"185.12.64.2"
];
# The interface MUST be explicit here. Since NixOS 25.05 the scripted-networking
# module installs the default route from the gateway interface's
# network-addresses-<iface>.service, and it finds that interface either by
# `defaultGateway.interface` or by the gateway address being inside one of the
# interface's subnets. With Hetzner's off-subnet point-to-point gateway
# (91.98.47.73/32 on eth0, gateway 172.31.1.1) neither matched when this was a
# bare string, so NO default route was installed and the 26.05 rebuild on
# 2026-08-03 took the host off the network (recovered via rescue mode).
defaultGateway = {
address = "172.31.1.1";
interface = "eth0";
};
# No IPv6 on this Hetzner instance (link-local only) — nixos-infect emitted an empty
# defaultGateway6/ipv6.route which made network-addresses-eth0.service fail
# ("ip route add /128" with no prefix). v4-only box, so no IPv6 gateway/route declared.
dhcpcd.enable = false;
usePredictableInterfaceNames = lib.mkForce false;
interfaces = {
eth0 = {
ipv4.addresses = [
{ address = "91.98.47.73"; prefixLength = 32; }
];
ipv4.routes = [{ address = "172.31.1.1"; prefixLength = 32; }];
};
};
};
services.udev.extraRules = ''
ATTR{address}=="92:00:08:04:15:2e", NAME="eth0"
'';
}