From d0a149fbe1984b6bbccf0c12cd67faa4d3e50519 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 3 Dec 2026 00:59:52 +0000 Subject: wiregrill: route each peer's addresses on the hub Peers' subnets are empty but for the hub's, so the hub had no route to any other host. The other hosts have only hubs as peers: those without an endpoint were of no use to them. --- configs/wiregrill.nix | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'configs') diff --git a/configs/wiregrill.nix b/configs/wiregrill.nix index d9e407d1..b8d23f49 100644 --- a/configs/wiregrill.nix +++ b/configs/wiregrill.nix @@ -3,6 +3,9 @@ enable = cfg.net != null; net = config.krebs.build.host.nets.wiregrill or null; }; + # The hub is the host with a public address; the others reach each other + # through it. + isHub = cfg.net.via != null; toCidrNotation = ip: "${ip.addr}/${toString ip.prefixLength}"; keyType = "application/x-wireguard-private-key"; keySlot = config.enstate.channels.secrets.slots."wiregrill.key"; @@ -33,7 +36,12 @@ in allowedIPsAsRoutes = true; peers = lib.mapAttrsToList (_: host: { - allowedIPs = host.nets.wiregrill.wireguard.subnets; + allowedIPs = + lib.optionals isHub ( + lib.optional (host.nets.wiregrill.ip4 != null) host.nets.wiregrill.ip4.addr ++ + lib.optional (host.nets.wiregrill.ip6 != null) host.nets.wiregrill.ip6.addr + ) ++ + host.nets.wiregrill.wireguard.subnets; endpoint = lib.mkIf (host.nets.wiregrill.via != null) (host.nets.wiregrill.via.ip4.addr + ":${toString host.nets.wiregrill.wireguard.port}"); persistentKeepalive = lib.mkIf (host.nets.wiregrill.via != null) 61; @@ -43,7 +51,8 @@ in (lib.filterAttrs (name: host: name != config.krebs.build.host.name && - lib.hasAttr "wiregrill" host.nets) + lib.hasAttr "wiregrill" host.nets && + (isHub || host.nets.wiregrill.via != null)) config.krebs.hosts); }; systemd.network.networks.wiregrill = { -- cgit v1.3.1 [cgit] Unable to lock slot /tmp/cgit/45100000.lock: Permission denied (13)