diff --git a/hosts/stroopwafel/networking.nix b/hosts/stroopwafel/networking.nix index 2931f3c..8ac00ba 100644 --- a/hosts/stroopwafel/networking.nix +++ b/hosts/stroopwafel/networking.nix @@ -31,4 +31,14 @@ endpoint = "146.70.134.2:3565"; }; }; + + age.secrets.wg-pub-solar-key.file = "${flake.self}/secrets/wg-pub-solar-stroopwafel.age"; + + pub-solar.wireguard.pub-solar = { + ownIPs = [ + "10.7.6.200/32" + "fd00:fae:fae:fae:fae:200::/96" + ]; + privateKeyFile = config.age.secrets.wg-pub-solar-key.path; + }; } diff --git a/modules/wireguard/default.nix b/modules/wireguard/default.nix index 9fe3d48..a1de81d 100644 --- a/modules/wireguard/default.nix +++ b/modules/wireguard/default.nix @@ -7,5 +7,6 @@ imports = [ ./private.nix ./tunnel.nix + ./pub.solar.nix ]; } diff --git a/modules/wireguard/pub.solar.nix b/modules/wireguard/pub.solar.nix new file mode 100644 index 0000000..82f478a --- /dev/null +++ b/modules/wireguard/pub.solar.nix @@ -0,0 +1,68 @@ +{ + lib, + config, + pkgs, + ... +}: +with lib; let + psCfg = config.pub-solar; + cfg = config.pub-solar.wireguard.pub-solar; +in { + options.pub-solar.wireguard.pub-solar = { + ownIPs = mkOption { + description = "Internal ips in wireguard used for cluster control-plane communication."; + type = types.listOf types.str; + default = []; + }; + + privateKeyFile = mkOption { + description = "Location of private key file"; + type = types.path; + }; + }; + + config = mkIf (length cfg.ownIPs != 0){ + networking.firewall.allowedUDPPorts = [51821]; + + systemd.services.wireguard-wg-pub-solar = { + enable = false; + + after = [ + "network.target" + "network-online.target" + "nss-lookup.target" + ]; + + serviceConfig = { + Type = mkForce "simple"; + Restart = "on-failure"; + RestartSec = "30"; + }; + + environment = { + WG_ENDPOINT_RESOLUTION_RETRIES = "infinity"; + }; + }; + + networking.wireguard.interfaces = { + wg-pub-solar = { + listenPort = 51821; + mtu = 1300; + ips = cfg.ownIPs; + privateKeyFile = cfg.privateKeyFile; + peers = [ + { + endpoint = "flora6.pub.solar:51820"; + publicKey = "jtSR5G2P/nm9s8WrVc26Xc/SQLupRxyXE+5eIeqlsTU="; + allowedIPs = [ "10.7.6.2/32" "fd00:fae:fae:fae:fae:2::/96" ]; + } + { + endpoint = "nachtigall.pub.solar:51820"; + publicKey = "qzNywKY9RvqTnDO8eLik75/SHveaSk9OObilDzv+xkk="; + allowedIPs = [ "10.7.6.1/32" "fd00:fae:fae:fae:fae:1::/96" ]; + } + ]; + }; + }; + }; +} diff --git a/secrets/secrets.nix b/secrets/secrets.nix index 7aa4443..7427524 100644 --- a/secrets/secrets.nix +++ b/secrets/secrets.nix @@ -84,6 +84,8 @@ in { "wg-tunnel-stroopwafel.age".publicKeys = stroopwafelKeys ++ baseKeys; "wg-tunnel-droppie.age".publicKeys = droppieKeys ++ baseKeys; + "wg-pub-solar-stroopwafel.age".publicKeys = stroopwafelKeys ++ baseKeys; + "invoiceplane-db-password.age".publicKeys = pieKeys ++ baseKeys; "invoiceplane-db-secrets.env.age".publicKeys = pieKeys ++ baseKeys; diff --git a/secrets/wg-pub-solar-stroopwafel.age b/secrets/wg-pub-solar-stroopwafel.age new file mode 100644 index 0000000..934cbc4 --- /dev/null +++ b/secrets/wg-pub-solar-stroopwafel.age @@ -0,0 +1,24 @@ +age-encryption.org/v1 +-> ssh-ed25519 b0WFDg FVT9AEwFAJ05+ximaSsEIdfW/HD7ZvUUFwwB26GDNQM +sWo3Cewxl6NFyj6+I5fFRv675ehncRsAA+oLNzO2jNs +-> ssh-rsa kFDS0A +gJiz5L1u7Y5UPeH1dcjkHOhMJ38taEuOt9tkTc+BRqjsGN50rW/gtJuJyBMwI3v5 +odxVJcWgp6uZMMJdTN6L7e7YRcDbZUbbKYcnQbuAE3mb1y0WrZLRbLfWS7eNTB3d +CRNeqfVn7Tg2e/r2kwLWmZb2HdMn0t6Yv1adPkQ1kkmkrzHPfpgfxdyxZ1WzEOnV +g7WgxYw0mmLpnN2n1PPSSvAn/v8u4sj+7vMszoRIEgyVSRwDxKGR3qo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