hetzner.nix

 1# Hetzner Cloud: networking and resolvers.
 2#
 3# `host` is this machine's entry from hosts.json (a specialArg).
 4{ host, lib, ... }:
 5
 6{
 7  # IPv4 comes from Hetzner's DHCP. Hetzner Cloud doesn't hand out IPv6 via
 8  # DHCP/RA, so the address `just new-host` read from the Debian image is set
 9  # statically, with Hetzner's fixed link-local gateway.
10  systemd.network.networks."10-uplink" = {
11    matchConfig.Type = "ether";
12    networkConfig = {
13      DHCP = "ipv4";
14      IPv6AcceptRA = false;
15    };
16    address = lib.optional (host.ipv6 or null != null) host.ipv6;
17    routes = lib.optional (host.ipv6 or null != null) { Gateway = "fe80::1"; };
18  };
19
20  # Hetzner's recursive resolvers, reachable only from Hetzner's network.
21  services.resolved.settings.Resolve.DNS = [
22    "185.12.64.1"
23    "185.12.64.2"
24    "2a01:4ff:ff00::add:1"
25    "2a01:4ff:ff00::add:2"
26  ];
27}